From 1b757a806cdff2691719a170279962ec8ddbf37d Mon Sep 17 00:00:00 2001 From: Yana Date: Mon, 13 Jan 2025 15:02:24 +0200 Subject: [PATCH] Refactor NodeTable to spectreDao api endpoint --- explorer-nextjs/src/actions/getNymNodes.ts | 8 +++---- .../src/components/nodeTable/NodeTable.tsx | 22 ++++++------------- .../nodeTable/NodeTableWithAction.tsx | 12 +++++----- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/explorer-nextjs/src/actions/getNymNodes.ts b/explorer-nextjs/src/actions/getNymNodes.ts index d42234aa06..70d214c683 100644 --- a/explorer-nextjs/src/actions/getNymNodes.ts +++ b/explorer-nextjs/src/actions/getNymNodes.ts @@ -1,8 +1,8 @@ -import type NymNode from "@/app/api/types"; -import { NYM_NODES } from "@/app/api/urls"; +import type { IObservatoryNode } from "@/app/api/types"; +import { DATA_OBSERVATORY_NODES_URL } from "@/app/api/urls"; -const getNymNodes = async (): Promise => { - const response = await fetch(`${NYM_NODES}`, { +const getNymNodes = async (): Promise => { + const response = await fetch(`${DATA_OBSERVATORY_NODES_URL}`, { next: { revalidate: 900, }, diff --git a/explorer-nextjs/src/components/nodeTable/NodeTable.tsx b/explorer-nextjs/src/components/nodeTable/NodeTable.tsx index db456571d0..b0215dc840 100644 --- a/explorer-nextjs/src/components/nodeTable/NodeTable.tsx +++ b/explorer-nextjs/src/components/nodeTable/NodeTable.tsx @@ -117,7 +117,7 @@ const NodeTable = ({ nodes }: { nodes: MappedNymNodes }) => { } setSelectedNodeForStaking({ nodeId: node.nodeId, - identityKey: node.bondInformation.node.identity_key, + identityKey: node.identity_key, }); }, [isWalletConnected], @@ -133,9 +133,7 @@ const NodeTable = ({ nodes }: { nodes: MappedNymNodes }) => { Cell: ({ row }) => ( {row.original.nodeId} - - {row.original.bondInformation.node.identity_key} - + {row.original.identity_key} ), }, @@ -153,16 +151,12 @@ const NodeTable = ({ nodes }: { nodes: MappedNymNodes }) => { accessorKey: "location.country_name", Header: Location, Cell: ({ row }) => - row.original.location?.two_letter_iso_country_code ? ( - + row.original.countryCode && row.original.countryName ? ( + @@ -214,9 +208,7 @@ const NodeTable = ({ nodes }: { nodes: MappedNymNodes }) => { accessorKey: "Favorite", Header: Favorite, sortingFn: "Favorite", - Cell: ({ row }) => ( - - ), + Cell: ({ row }) => , }, ], [isWalletConnected, handleOnSelectStake], diff --git a/explorer-nextjs/src/components/nodeTable/NodeTableWithAction.tsx b/explorer-nextjs/src/components/nodeTable/NodeTableWithAction.tsx index f061e2b585..12a23b9941 100644 --- a/explorer-nextjs/src/components/nodeTable/NodeTableWithAction.tsx +++ b/explorer-nextjs/src/components/nodeTable/NodeTableWithAction.tsx @@ -1,16 +1,18 @@ import getNymNodes from "@/actions/getNymNodes"; -import type NymNode from "@/app/api/types"; +import type { IObservatoryNode } from "@/app/api/types"; import NodeTable from "./NodeTable"; -const mappedNymNodes = (nodes: NymNode[]) => +const mappedNymNodes = (nodes: IObservatoryNode[]) => nodes.map((node) => { return { nodeId: node.node_id, - bondInformation: node.bond_information, - location: node.location, + identity_key: node.identity_key, + countryCode: node.description.auxiliary_details.location || null, + countryName: node.description.auxiliary_details.location || null, profitMarginPercentage: +node.rewarding_details.cost_params.profit_margin_percent * 100, - description: node.description, + + owner: node.bonding_address, }; });