diff --git a/packages/app-explorer/src/systems/Core/components/Layout/Layout.tsx b/packages/app-explorer/src/systems/Core/components/Layout/Layout.tsx index 55b3bd8d..82e80843 100644 --- a/packages/app-explorer/src/systems/Core/components/Layout/Layout.tsx +++ b/packages/app-explorer/src/systems/Core/components/Layout/Layout.tsx @@ -1,8 +1,10 @@ 'use client'; -import { Container, VStack } from '@fuels/ui'; +import { Container, LoadingBox, VStack } from '@fuels/ui'; import { usePathname } from 'next/navigation'; -import { Hero } from '~/systems/Home/components/Hero/Hero'; +const Hero = React.lazy(() => import('~/systems/Home/components/Hero/Hero')); +import { DateTime } from 'fuels'; +import React, { Suspense } from 'react'; import { cx } from '../../utils/cx'; import { Footer } from '../Footer/Footer'; import { TopNav } from '../TopNav/TopNav'; @@ -15,11 +17,15 @@ export type LayoutProps = { export function Layout({ children, contentClassName }: LayoutProps) { const pathname = usePathname(); const isHomePage = pathname === '/'; - + console.log('Page loaded', DateTime.now); return ( - {isHomePage && } + {isHomePage && ( + }> + + + )} { ); }; +export default DataTable; diff --git a/packages/app-explorer/src/systems/Home/components/GasSpentChart/index.tsx b/packages/app-explorer/src/systems/Home/components/GasSpentChart/index.tsx index 403e0428..0ce8f090 100644 --- a/packages/app-explorer/src/systems/Home/components/GasSpentChart/index.tsx +++ b/packages/app-explorer/src/systems/Home/components/GasSpentChart/index.tsx @@ -20,7 +20,7 @@ const chartConfig = { interface GasSpentProps { blocks: any; } -export const GasSpentChart = (gasSpent: GasSpentProps) => { +const GasSpentChart = (gasSpent: GasSpentProps) => { const totalGasSpent = gasSpent.blocks .map((block: any) => +block.value) .reduce((acc: any, value: any) => acc + value, 0); @@ -141,3 +141,4 @@ export const GasSpentChart = (gasSpent: GasSpentProps) => { ); }; +export default GasSpentChart; diff --git a/packages/app-explorer/src/systems/Home/components/Hero/Hero.tsx b/packages/app-explorer/src/systems/Home/components/Hero/Hero.tsx index 65c8337e..1252fa66 100644 --- a/packages/app-explorer/src/systems/Home/components/Hero/Hero.tsx +++ b/packages/app-explorer/src/systems/Home/components/Hero/Hero.tsx @@ -1,22 +1,19 @@ -'use client'; - import { Box, Container, Heading, Theme, VStack } from '@fuels/ui'; - import { LoadingBox, LoadingWrapper } from '@fuels/ui'; -import { useEffect, useState } from 'react'; +import React, { Suspense, useEffect, useState } from 'react'; import { tv } from 'tailwind-variants'; import projectJson from '../../../../../../app-portal/src/systems/Ecosystem/data/projects.json'; -import { DataTable } from '../../components/DataTable'; -import { Block } from '../../interface/blocks.interface'; -import DailyTransaction from '../DailyTransaction'; -import { GasSpentChart } from '../GasSpentChart'; -import { LatestBlock } from '../LatestBlock'; -import { TPS } from '../TPS'; -import TotalDapps from '../TotalDapps/TotalDapps'; import { getBlocksDashboard } from './actions/get-blocks-dashboard'; import { getTPS } from './actions/get-tps'; -export function Hero() { +const DailyTransaction = React.lazy(() => import('../DailyTransaction')); +const GasSpentChart = React.lazy(() => import('../GasSpentChart/index')); +const LatestBlock = React.lazy(() => import('../LatestBlock')); +const TPS = React.lazy(() => import('../TPS')); +const TotalDapps = React.lazy(() => import('../TotalDapps/TotalDapps')); +const DataTable = React.lazy(() => import('../../components/DataTable')); + +function Hero() { const classes = styles(); const [isLoading, setIsLoading] = useState(true); const [tpsData, setTpsData] = useState(null); @@ -25,25 +22,27 @@ export function Hero() { const getTPSData = async () => { try { - const result = await getTPS(); - const dashboard = await getBlocksDashboard(); + const [result, dashboard] = await Promise.all([ + getTPS(), + getBlocksDashboard(), + ]); + setIsLoading(false); setTpsData(result); - setBlocksData(dashboard); if (isFirstFetch) { - setIsLoading(false); // Set loading to false only after first fetch - setIsFirstFetch(false); // Mark that the first fetch is done + setIsLoading(false); + setIsFirstFetch(false); } } catch (_e) {} }; useEffect(() => { + getTPSData(); const interval = setInterval(() => { getTPSData(); }, 10000); - return () => clearInterval(interval); }, []); @@ -93,19 +92,19 @@ export function Hero() { Fuel Explorer - {/* - Trending Items - -
- -
*/}
} - regularEl={} + regularEl={ + } + > + + + } />
@@ -113,11 +112,15 @@ export function Hero() { isLoading={isLoading} loadingEl={} regularEl={ - + } + > + + } />
@@ -126,33 +129,43 @@ export function Hero() { isLoading={isLoading} loadingEl={} regularEl={ - + } + > + + } /> -
+
} - regularEl={} + regularEl={ + } + > + + + } />
@@ -160,16 +173,25 @@ export function Hero() { } - regularEl={} + regularEl={ + } + > + + + } /> - {/* */}
- } - regularEl={} - /> + } + > + } + regularEl={} + /> +
@@ -203,3 +225,4 @@ const styles = tv({ ], }, }); +export default Hero; diff --git a/packages/app-explorer/src/systems/Home/components/LatestBlock.tsx b/packages/app-explorer/src/systems/Home/components/LatestBlock.tsx index 652b9903..5feb0680 100644 --- a/packages/app-explorer/src/systems/Home/components/LatestBlock.tsx +++ b/packages/app-explorer/src/systems/Home/components/LatestBlock.tsx @@ -3,7 +3,7 @@ import { HStack, RoundedContainer, VStack } from '@fuels/ui'; import { fromNow } from '~/systems/Core/utils/dayjs'; import { Block } from '../interface/blocks.interface'; -export const LatestBlock = (block: Block) => { +const LatestBlock = (block: Block) => { return (
@@ -61,3 +61,4 @@ export const LatestBlock = (block: Block) => { ); }; +export default LatestBlock; diff --git a/packages/app-explorer/src/systems/Home/components/TPS.tsx b/packages/app-explorer/src/systems/Home/components/TPS.tsx index 385d64aa..86dd94b3 100644 --- a/packages/app-explorer/src/systems/Home/components/TPS.tsx +++ b/packages/app-explorer/src/systems/Home/components/TPS.tsx @@ -148,3 +148,4 @@ export const TPS = (props: TPSProps) => { ); }; +export default TPS;