import React, { useMemo } from 'react'; import { Flex, Icon, IconName, ResolvedAddress, Text } from '@/components'; import { IndexedNFA } from '../indexed-nfa.context'; import { IndexedNFAStyles as S } from '../indexed-nfa.styles'; type HeaderDataProps = { label: string; children: React.ReactNode; }; const HeaderData: React.FC = ({ label, children, }: HeaderDataProps) => ( {label} {children} ); const Header: React.FC = () => { const { nfa } = IndexedNFA.useContext(); return ( <> {nfa.name} {nfa.owner.id} {/* TODO: place correct data */} 12/12/22 {nfa.accessPoints?.length ?? 0} ); }; const Description: React.FC = () => { const { nfa } = IndexedNFA.useContext(); return ( <> Description {nfa.description} ); }; type DataWrapperProps = React.PropsWithChildren<{ label: string | number; }>; const DataWrapper: React.FC = ({ children, label, }: DataWrapperProps) => ( {children || '-'} {label} ); const Traits: React.FC = () => { const { nfa } = IndexedNFA.useContext(); // TODO: place correct data const traitsToShow = useMemo(() => { return [ [nfa.ENS, 'ENS'], [nfa.gitRepository.id, 'Repository'], [10, 'Version'], [nfa.externalURL, 'Domain'], [nfa.externalURL, 'Domain 2'], ]; }, [nfa]); return ( <> Traits {traitsToShow.map(([value, label]) => ( {value} ))} ); }; type VerificationBannerProps = { verified: boolean; }; const VerificationBanner: React.FC = ({ verified, }: VerificationBannerProps) => { const [text, icon] = useMemo<[string, IconName]>(() => { if (verified) return ['This Non Fungible Application is Verified.', 'verified']; return ['This Non Fungible Application is not Verified.', 'error']; }, [verified]); return ( {text} ); }; const Verification: React.FC = () => { return ( <> Verification {/* TODO: Get verified from context */} 0.5} /> {/* TODO: place correct data */} polygon.eth polygon/fe ); }; // TODO: replace mocks with fetched data const apMocks = new Array(10).fill(0).map((_, index) => ({ approved: Math.random() > 0.5, domain: `domain${index}.com`, owner: '0x7ED735b7095C05d78dF169F991f2b7f1A1F1A049', createdAt: `${Math.floor(Math.random() * 30)}m ago`, })); const AccessPoints: React.FC = () => { return ( <> Frontends Domain Owner Created {apMocks.map((item) => ( {item.domain} {item.owner} {item.createdAt} ))} ); }; // TODO: replace mocks with fetched data const versionsMock = new Array(10).fill(0).map((_, index) => ({ live: index === 0, commit: (Math.random() * 0xfffffffff).toString(16), preview: `test: subgraph matchstick tests for access points and acl refactor (#150 ) * fix: errors from deprecated entities.`, time: `${Math.floor(Math.random() * 30)}m ago`, })); const Versions: React.FC = () => { return ( <> Versions Commit Preview Time {versionsMock.map((item) => ( {item.live && 'Live'} {item.commit.slice(0, 6)} {item.preview} {item.time} ))} ); }; export const IndexedNFAMainFragment: React.FC = () => { return (
); };