Refactor NodeTable to spectreDao api endpoint
This commit is contained in:
@@ -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<NymNode[]> => {
|
||||
const response = await fetch(`${NYM_NODES}`, {
|
||||
const getNymNodes = async (): Promise<IObservatoryNode[]> => {
|
||||
const response = await fetch(`${DATA_OBSERVATORY_NODES_URL}`, {
|
||||
next: {
|
||||
revalidate: 900,
|
||||
},
|
||||
|
||||
@@ -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 }) => (
|
||||
<Stack spacing={1}>
|
||||
<Typography variant="body4">{row.original.nodeId}</Typography>
|
||||
<Typography variant="body5">
|
||||
{row.original.bondInformation.node.identity_key}
|
||||
</Typography>
|
||||
<Typography variant="body5">{row.original.identity_key}</Typography>
|
||||
</Stack>
|
||||
),
|
||||
},
|
||||
@@ -153,16 +151,12 @@ const NodeTable = ({ nodes }: { nodes: MappedNymNodes }) => {
|
||||
accessorKey: "location.country_name",
|
||||
Header: <ColumnHeading>Location</ColumnHeading>,
|
||||
Cell: ({ row }) =>
|
||||
row.original.location?.two_letter_iso_country_code ? (
|
||||
<Tooltip title={row.original.location.country_name}>
|
||||
row.original.countryCode && row.original.countryName ? (
|
||||
<Tooltip title={row.original.countryName}>
|
||||
<Box>
|
||||
<CountryFlag
|
||||
countryCode={
|
||||
row.original.location.two_letter_iso_country_code
|
||||
}
|
||||
countryName={
|
||||
row.original.location.two_letter_iso_country_code
|
||||
}
|
||||
countryCode={row.original.countryCode || ""}
|
||||
countryName={row.original.countryCode || ""}
|
||||
/>
|
||||
</Box>
|
||||
</Tooltip>
|
||||
@@ -214,9 +208,7 @@ const NodeTable = ({ nodes }: { nodes: MappedNymNodes }) => {
|
||||
accessorKey: "Favorite",
|
||||
Header: <ColumnHeading>Favorite</ColumnHeading>,
|
||||
sortingFn: "Favorite",
|
||||
Cell: ({ row }) => (
|
||||
<Favorite address={row.original.bondInformation.owner} />
|
||||
),
|
||||
Cell: ({ row }) => <Favorite address={row.original.owner} />,
|
||||
},
|
||||
],
|
||||
[isWalletConnected, handleOnSelectStake],
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user