"use client"; import { Table } from "@pythnetwork/component-library/Table"; import { useMemo } from "react"; import { useCollator } from "react-aria"; import styles from "./reference-data.module.scss"; import { AssetClassTag } from "../AssetClassTag"; import { LiveValue } from "../LivePrices"; type Props = { feed: { symbol: string; feedKey: string; assetClass: string; base?: string | undefined; description: string; country?: string | undefined; quoteCurrency?: string | undefined; tenor?: string | undefined; cmsSymbol?: string | undefined; cqsSymbol?: string | undefined; nasdaqSymbol?: string | undefined; genericSymbol?: string | undefined; weeklySchedule?: string | undefined; schedule?: string | undefined; contractId?: string | undefined; displaySymbol: string; exponent: number; numComponentPrices: number; numQuoters: number; minPublishers: number; lastSlot: bigint; validSlot: bigint; }; }; export const ReferenceData = ({ feed }: Props) => { const collator = useCollator(); const rows = useMemo( () => [ ...Object.entries({ "Asset Type": , Base: feed.base, Description: feed.description, Symbol: feed.symbol, Country: feed.country, "Quote Currency": feed.quoteCurrency, Tenor: feed.tenor, "CMS Symbol": feed.cmsSymbol, "CQS Symbol": feed.cqsSymbol, "NASDAQ Symbol": feed.nasdaqSymbol, "Generic Symbol": feed.genericSymbol, "Weekly Schedule": feed.weeklySchedule, Schedule: feed.schedule, "Contract ID": feed.contractId, "Display Symbol": feed.displaySymbol, }), ...Object.entries({ Exponent: "exponent", "Number of Price Components": "numComponentPrices", "Number of Price Quoters": "numQuoters", "Minimum Number of Publishers": "minPublishers", "Last Slot": "lastSlot", "Valid Slot": "validSlot", } as const).map( ([key, value]) => [ key, , ] as const, ), ] .map(([field, value]) => value === undefined ? undefined : ([field, value] as const), ) .filter((entry) => entry !== undefined) .sort(([a], [b]) => collator.compare(a, b)) .map(([field, value]) => ({ id: field, data: { field: {field}, value: typeof value === "string" ? ( {value} ) : ( value ), }, })), [collator, feed], ); return ( ); };