Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #4

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ const nextConfig = {
return [
{
source: '/trustless-computers',
destination: '/blockchains',
destination: '/blockchains/computers',
permanent: false,
},
{
source: '/blockchains/dashboard',
source: '/bvm-website-sats',
destination: '/blockchains/computers',
permanent: false,
},
{
source: '/blockchains/computers',
destination: '/blockchains',
permanent: false,
},
];
},

Expand Down
25 changes: 17 additions & 8 deletions src/app/blockchains/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,26 @@
import { isProduction } from '@/config';
import MainLayout from '@/layouts/MainLayout';
import IframeTC from '@/modules/iframe-tc';
import dynamic from 'next/dynamic';

const pathUrl = '/trustless-computers-iframe/';
// const IframeURLExtend = DOMAIN_URL + MAIN_PATH;
const pathUrl = '/bvm-website-sats-iframe/computers';
const IframeURLExtend =
'https://dev.newbitcoincity.com/trustless-computers-iframe/';
'http://localhost:6009/trustless-computers-iframe/dashboard';

// const iframeDomain = isProduction
// ? 'http://localhost:6009'
// : 'http://localhost:6009';

const iframeDomain = isProduction
? 'https://newbitcoincity.com'
: 'https://dev.newbitcoincity.com';
? 'https://bvm.network'
: 'https://dev.bvm.network';

const IframeTCDynamic = dynamic(
() => import('@/modules/iframe-tc').then((m) => m.default),
{
ssr: false,
},
);

const TCPage = () => {
return (
Expand All @@ -22,9 +33,7 @@ const TCPage = () => {
bgColor: 'white',
}}
>
{typeof document !== 'undefined' ? (
<IframeTC iframeURL={`${iframeDomain}${pathUrl}`} />
) : null}
<IframeTCDynamic iframeURL={`${iframeDomain}${pathUrl}`} />
</MainLayout>
);
};
Expand Down
32 changes: 0 additions & 32 deletions src/app/tc/page.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/layouts/Header/menuConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface NavItem {
export const NAV_ITEMS: Array<NavItem> = [
{
label: 'Blockchains',
href: '/blockchains',
href: '/blockchains/computers',
isNewWindow: false,
isHide: false,
},
Expand Down
27 changes: 24 additions & 3 deletions src/modules/iframe-tc/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use client';

import useWindowSize from '@/hooks/useWindowSize';
import { Flex, Spinner } from '@chakra-ui/react';
import { useEffect, useState } from 'react';
import s from './styles.module.scss';
import { useEffect } from 'react';

interface IProps {
iframeURL: string;
}

const IframeTC = (props: IProps) => {
const [iframeLoading, setIframeLoading] = useState(true);
const { heightWidth } = useWindowSize();
const elmHeader = document?.getElementById('header');

Expand All @@ -20,11 +22,26 @@ const IframeTC = (props: IProps) => {
elmHeader.click();
}
}
window.addEventListener('blur', blur);
setIframeLoading(false);
return () => window.removeEventListener('blur', blur);
}, [document]);

if (!document) return <></>;
if (!document) {
return <></>;
}
if (iframeLoading) {
return (
<Flex
flex={1}
minHeight={'100%'}
justify={'center'}
align={'center'}
bgColor={'white'}
>
<Spinner color={'black'}></Spinner>
</Flex>
);
}
return (
<div
className={s.container}
Expand All @@ -39,6 +56,10 @@ const IframeTC = (props: IProps) => {
src={props.iframeURL}
width="100%"
style={{ border: 'none' }}
onLoadedData={() => {}}
onLoad={() => {
setIframeLoading(false);
}}
/>
</div>
);
Expand Down