import { Box, Flex, chakra, createListCollection } from '@chakra-ui/react'; import React from 'react'; import type { TokenInstance } from 'types/api/token'; import { Alert } from 'toolkit/chakra/alert'; import type { SelectOption } from 'toolkit/chakra/select'; import { Select } from 'toolkit/chakra/select'; import { ContentLoader } from 'toolkit/components/loaders/ContentLoader'; import CopyToClipboard from 'ui/shared/CopyToClipboard'; import RawDataSnippet from 'ui/shared/RawDataSnippet'; import { useMetadataUpdateContext } from './contexts/metadataUpdate'; import MetadataAccordion from './metadata/MetadataAccordion'; const OPTIONS = [ { label: 'Table', value: 'Table' as const }, { label: 'JSON', value: 'JSON' as const }, ]; const collection = createListCollection({ items: OPTIONS }); type Format = (typeof OPTIONS)[number]['value']; interface Props { data: TokenInstance['metadata'] | undefined; isPlaceholderData?: boolean; } const TokenInstanceMetadata = ({ data, isPlaceholderData }: Props) => { const [ format, setFormat ] = React.useState>([ 'Table' ]); const { status: refetchStatus } = useMetadataUpdateContext() || {}; const handleValueChange = React.useCallback(({ value }: { value: Array }) => { setFormat(value as Array); }, []); if (isPlaceholderData || refetchStatus === 'WAITING_FOR_RESPONSE') { return ; } if (!data) { return There is no metadata for this NFT; } const content = format[0] === 'Table' ? : ; return ( { refetchStatus === 'ERROR' && ( We { `couldn't` } refresh metadata. Please try again now or later. ) } Metadata