add identity_key params possibility to node-page
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fetchNodeInfo } from "@/app/api";
|
||||
import { fetchNodeIdByIdentityKey, fetchNodeInfo } from "@/app/api";
|
||||
import { ContentLayout } from "@/components/contentLayout/ContentLayout";
|
||||
import SectionHeading from "@/components/headings/SectionHeading";
|
||||
import { BasicInfoCard } from "@/components/nymNodePageComponents/BasicInfoCard";
|
||||
@@ -18,7 +18,16 @@ export default async function NymNode({
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
try {
|
||||
const id = Number((await params).id);
|
||||
let id: string | number;
|
||||
const paramsId = (await params).id;
|
||||
|
||||
// check if the params id is a node_id or identity_key
|
||||
|
||||
if (paramsId.length > 10) {
|
||||
id = await fetchNodeIdByIdentityKey(paramsId);
|
||||
} else {
|
||||
id = Number(paramsId);
|
||||
}
|
||||
|
||||
const observatoryNymNode = await fetchNodeInfo(id);
|
||||
|
||||
|
||||
@@ -64,6 +64,14 @@ export const fetchNodeInfo = async (
|
||||
return nodes?.find((node) => node.node_id === id);
|
||||
};
|
||||
|
||||
export const fetchNodeIdByIdentityKey = async (
|
||||
identity_key: string,
|
||||
): Promise<number> => {
|
||||
const nodes = await fetchObservatoryNodes();
|
||||
const node = nodes?.find((node) => node.identity_key === identity_key);
|
||||
return node?.node_id || 0;
|
||||
};
|
||||
|
||||
export const fetchNodeDelegations = async (
|
||||
id: number,
|
||||
): Promise<NodeRewardDetails[]> => {
|
||||
|
||||
Reference in New Issue
Block a user