diff --git a/explorer-nextjs/src/app/(pages)/nym-node/[id]/page.tsx b/explorer-nextjs/src/app/(pages)/nym-node/[id]/page.tsx index 24ede6fad9..995cc3263a 100644 --- a/explorer-nextjs/src/app/(pages)/nym-node/[id]/page.tsx +++ b/explorer-nextjs/src/app/(pages)/nym-node/[id]/page.tsx @@ -2,8 +2,10 @@ import type NodeData from "@/app/api/types"; import type { IObservatoryNode } from "@/app/api/types"; import { DATA_OBSERVATORY_NODES_URL, NYM_NODES } from "@/app/api/urls"; import BlogArticlesCards from "@/components/blogs/BlogArticleCards"; +import ExplorerCard from "@/components/cards/ExplorerCard"; import { ContentLayout } from "@/components/contentLayout/ContentLayout"; import SectionHeading from "@/components/headings/SectionHeading"; +import DelegationsTable from "@/components/nodeTable/DelegationsTable"; import { BasicInfoCard } from "@/components/nymNodePageComponents/BasicInfoCard"; import { NodeChatCard } from "@/components/nymNodePageComponents/ChatCard"; import { NodeMetricsCard } from "@/components/nymNodePageComponents/NodeMetricsCard"; @@ -60,6 +62,19 @@ export default async function NymNode({ if (!nymNode) { return null; } + const nodeDelegationsResponse = await fetch( + `${DATA_OBSERVATORY_NODES_URL}/${id}/delegations`, + { + headers: { + Accept: "application/json", + "Content-Type": "application/json; charset=utf-8", + }, + next: { revalidate: 60 }, + // refresh event list cache at given interval + }, + ); + + const delegations = await nodeDelegationsResponse.json(); return ( @@ -134,6 +149,18 @@ export default async function NymNode({ nodeId={nymNode.bond_information.node_id} /> + {delegations && ( + + + + + + )} + { return ( - - {countryName} - + {countryName && ( + + {countryName} + + )} ); }; diff --git a/explorer-nextjs/src/components/nodeTable/DelegationsTable.tsx b/explorer-nextjs/src/components/nodeTable/DelegationsTable.tsx new file mode 100644 index 0000000000..7aa7a69ab7 --- /dev/null +++ b/explorer-nextjs/src/components/nodeTable/DelegationsTable.tsx @@ -0,0 +1,137 @@ +"use client"; + +import type { NodeRewardDetails } from "@/app/api/types"; +import { Stack, Typography } from "@mui/material"; +import { + type MRT_ColumnDef, + MaterialReactTable, + useMaterialReactTable, +} from "material-react-table"; +import { useRouter } from "next/navigation"; +import { useMemo } from "react"; + +const ColumnHeading = ({ + children, +}: { + children: string | React.ReactNode; +}) => { + return ( + + {children} + + ); +}; + +const getNymsFormated = (unyms: string) => { + const balance = Number(unyms) / 1000000; + return balance.toFixed(); +}; + +const DelegationsTable = ({ + delegations, +}: { + delegations: NodeRewardDetails[]; +}) => { + const router = useRouter(); + + const columns: MRT_ColumnDef[] = useMemo( + () => [ + { + id: "height", + header: "", + Header: Height, + accessorKey: "height", + Cell: ({ row }) => ( + + {row.original.height} + + ), + }, + { + id: "address", + header: "Delegation Address", + align: "center", + accessorKey: "address", + Header: Delegation Address, + Cell: ({ row }) => ( + {row.original.owner} + ), + }, + { + id: "amount", + header: "Amount", + accessorKey: "amount", + Header: Amount, + Cell: ({ row }) => ( + + {getNymsFormated(row.original.amount.amount)} NYM + + ), + }, + ], + [], + ); + const table = useMaterialReactTable({ + columns, + data: delegations, + enableRowSelection: false, //enable some features + enableColumnOrdering: false, //enable a feature for all columns + enableColumnActions: false, + enableFullScreenToggle: false, + enableHiding: false, + paginationDisplayMode: "pages", + muiPaginationProps: { + showRowsPerPage: false, + SelectProps: { + sx: { + fontFamily: "labGrotesqueMono", + fontSize: "14px", + }, + }, + color: "primary", + shape: "circular", + }, + initialState: { + columnPinning: { right: ["Amount"] }, + }, + + muiColumnActionsButtonProps: { + sx: { + color: "red", + }, + size: "small", + }, + muiTablePaperProps: { + elevation: 0, + }, + muiTableHeadRowProps: { + sx: { + bgcolor: "background.paper", + }, + }, + + muiTableBodyCellProps: { + sx: { + border: "none", + }, + }, + muiTableBodyRowProps: ({ row }) => ({ + onClick: () => { + router.push(`/account/${row.original.owner}`); + }, + hover: true, + sx: { + ":nth-child(odd)": { + bgcolor: "#F3F7FB !important", + }, + ":nth-child(even)": { + bgcolor: "white !important", + }, + cursor: "pointer", + }, + }), + }); + return ; +}; + +export default DelegationsTable; diff --git a/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx b/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx index f9e31e0688..048c616f7e 100644 --- a/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx +++ b/explorer-nextjs/src/components/nymNodePageComponents/QualityIndicatorsCard.tsx @@ -1,4 +1,4 @@ -import type { NodeDescription } from "@/app/api/types"; +import type { IObservatoryNode, NodeDescription } from "@/app/api/types"; import { Chip, Stack } from "@mui/material"; import ExplorerCard from "../cards/ExplorerCard"; import ExplorerListItem from "../list/ListItem"; @@ -6,6 +6,7 @@ import StarRating from "../starRating/StarRating"; interface IQualityIndicatorsCardProps { nodeDescription: NodeDescription; + nodeInfo?: IObservatoryNode; } type NodeDescriptionNotNull = NonNullable; @@ -30,7 +31,7 @@ function getNodeRoles( } export const QualityIndicatorsCard = (props: IQualityIndicatorsCardProps) => { - const { nodeDescription } = props; + const { nodeDescription, nodeInfo } = props; if (!nodeDescription) { return null; @@ -43,6 +44,8 @@ export const QualityIndicatorsCard = (props: IQualityIndicatorsCardProps) => { )); + console.log("activeRoles :>> ", nodeDescription.declared_role); + return (