diff --git a/explorer-nextjs/src/app/account/[address]/page.tsx b/explorer-nextjs/src/app/account/[address]/page.tsx new file mode 100644 index 0000000000..cfac6556d1 --- /dev/null +++ b/explorer-nextjs/src/app/account/[address]/page.tsx @@ -0,0 +1,103 @@ +import type { CurrencyRates, IAccountBalancesInfo } from "@/app/api/types"; +import type NodeData from "@/app/api/types"; +import { NYM_ACCOUNT_ADDRESS, NYM_NODES, NYM_PRICES_API } from "@/app/api/urls"; +import { AccountBalancesCard } from "@/components/accountPageComponents/AccountBalancesCard"; +import { AccountInfoCard } from "@/components/accountPageComponents/AccountInfoCard"; +import { ContentLayout } from "@/components/contentLayout/ContentLayout"; +import SectionHeading from "@/components/headings/SectionHeading"; +import ExplorerButtonGroup from "@/components/toggleButton/ToggleButton"; +import { Box, Grid2, Typography } from "@mui/material"; + +export default async function Account({ + params, +}: { + params: Promise<{ address: string }>; +}) { + try { + const { address } = await params; + + const accountData = await fetch(`${NYM_ACCOUNT_ADDRESS}${address}`, { + headers: { + Accept: "application/json", + "Content-Type": "application/json; charset=utf-8", + }, + next: { revalidate: 60 }, + // refresh event list cache at given interval + }); + + const response = await fetch(NYM_NODES, { + headers: { + Accept: "application/json", + "Content-Type": "application/json; charset=utf-8", + }, + next: { revalidate: 60 }, + // refresh event list cache at given interval + }); + + const nymNodes: NodeData[] = await response.json(); + + const nymNode = nymNodes.find( + (node) => node.bond_information.owner === address, + ); + + const nymAccountBalancesData: IAccountBalancesInfo = + await accountData.json(); + + if (!nymAccountBalancesData) { + return Account not found; + } + + const nymPrice = await fetch(NYM_PRICES_API, { + headers: { + Accept: "application/json", + "Content-Type": "application/json; charset=utf-8", + }, + next: { revalidate: 60 }, + // refresh event list cache at given interval + }); + + const nymPriceData: CurrencyRates = await nymPrice.json(); + + return ( + + + + + + + + + + + + + + + + + + + ); + } catch (error) { + console.error("error :>> ", error); + return Error loading account data; + } +} diff --git a/explorer-nextjs/src/app/account/[id]/page.tsx b/explorer-nextjs/src/app/account/[id]/page.tsx deleted file mode 100644 index b641e82438..0000000000 --- a/explorer-nextjs/src/app/account/[id]/page.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import type { CurrencyRates, IAccountBalancesInfo } from "@/app/api/types"; -import { NYM_ACCOUNT_ADDRESS, NYM_PRICES_API } from "@/app/api/urls"; -import { AccountBalancesCard } from "@/components/accountPageComponents/AccountBalancesCard"; -import { AccountInfoCard } from "@/components/accountPageComponents/AccountInfoCard"; -import { ContentLayout } from "@/components/contentLayout/ContentLayout"; -import SectionHeading from "@/components/headings/SectionHeading"; -import ExplorerButtonGroup from "@/components/toggleButton/ToggleButton"; -import { Box, Grid2 } from "@mui/material"; - -export default async function Account({ - params, -}: { - params: Promise<{ address: string }>; -}) { - // const address = (await params).address; - console.log("(await params).address :>> ", (await params).address); - const address = "n1z0msxu8c098umdhnthpr2ac3ck2n3an97dm8pn"; - - const nymAccountAddress = `${NYM_ACCOUNT_ADDRESS}${address}`; - const accountData = await fetch(nymAccountAddress, { - headers: { - Accept: "application/json", - "Content-Type": "application/json; charset=utf-8", - }, - next: { revalidate: 60 }, - // refresh event list cache at given interval - }); - const nymAccountBalancesData: IAccountBalancesInfo = await accountData.json(); - - if (!nymAccountBalancesData) { - return null; - } - console.log("nymAccountBalancesData :>> ", nymAccountBalancesData); - const nymPrice = await fetch(NYM_PRICES_API, { - headers: { - Accept: "application/json", - "Content-Type": "application/json; charset=utf-8", - }, - next: { revalidate: 60 }, - // refresh event list cache at given interval - }); - - const nymPriceData: CurrencyRates = await nymPrice.json(); - - console.log("nymPriceData :>> ", nymPriceData); - - console.log("nymAccountData :>> ", nymAccountBalancesData); - return ( - - - - - - - - - - - - - - - - - - - ); -}