import Layout from '../../../components/layout' import { ITEM_OTS } from '../../../fragments/items' import { getGetServerSideProps } from '../../../api/ssrApollo' import stringifyCanon from 'canonical-json' import Button from 'react-bootstrap/Button' import { useQuery } from '@apollo/client' import { useRouter } from 'next/router' import PageLoading from '../../../components/page-loading' export const getServerSideProps = getGetServerSideProps({ query: ITEM_OTS, notFound: data => !data.item || !data.item.otsHash }) export default function OtsItem ({ ssrData }) { const router = useRouter() const { data } = useQuery(ITEM_OTS, { variables: { id: router.query.id } }) if (!data && !ssrData) return const { item } = data || ssrData return ( ) } function Ots ({ item }) { const itemString = stringifyCanon({ parentHash: item.parentOtsHash, title: item.title, text: item.text, url: item.url }) return ( <>
sha256 hash
{item.otsHash}
preimage
{item.deletedAt ?
item was deleted by author - original preimage is lost
: (
{itemString}
          
)}
merkle proof
) }