import { useMemo } from 'react'; import { Box, Flex, SkeletonText, Badge, VStack } from '@chakra-ui/react'; import ReactFlow from 'react-flow-renderer'; import { Background, ReactFlowProvider } from 'react-flow-renderer'; import { Handle, Position } from 'react-flow-renderer'; import { useConfig, useColorValue, useColorToken, useBreakpointValue } from '~/context'; import { useASNDetail } from '~/hooks'; import { Controls } from './controls'; import { buildElements } from './util'; import type { ReactFlowProps } from 'react-flow-renderer'; import type { TChart, TNode, TNodeData } from './types'; export const Chart = (props: TChart) => { const { data } = props; const { primary_asn, org_name } = useConfig(); const dots = useColorToken('blackAlpha.500', 'whiteAlpha.400'); const flowProps = useBreakpointValue>({ base: { defaultPosition: [0, 300], defaultZoom: 0 }, lg: { defaultPosition: [500, 450] }, }); const elements = useMemo(() => [...buildElements({ asn: primary_asn, name: org_name }, data)], [ data, ]); return ( ); }; const TestNode = (props: TNode) => { const { data } = props; const { asn, name, hasChildren, hasParents } = data; const color = useColorValue('black', 'white'); const bg = useColorValue('white', 'whiteAlpha.100'); const { data: asnData, isError, isLoading } = useASNDetail(asn); return ( <> {hasChildren && } {isLoading ? ( ) : !isError && asnData?.data?.description_short ? ( asnData.data.description_short ) : ( name )} {asn} {hasParents && } ); };