import { Alert } from 'components/Alert' import { Anchor } from 'components/Anchor' import { Button } from 'components/Button' import { Conditional } from 'components/Conditional' import { ContractPageHeader } from 'components/ContractPageHeader' import { useWallet } from 'contexts/wallet' import type { NextPage } from 'next' import { NextSeo } from 'next-seo' import { useCallback, useState } from 'react' import { FaRocket, FaSlidersH } from 'react-icons/fa' import { STARGAZE_URL } from 'utils/constants' import { withMetadata } from 'utils/layout' import { links } from 'utils/links' import type { CollectionData } from './create' const CollectionList: NextPage = () => { const wallet = useWallet() const [clearFlag, setClearFlag] = useState(false) let allCollections: Record[] = [] let myCollections: Record | undefined let myCollectionList: CollectionData[] = [] if (typeof localStorage !== 'undefined') { allCollections = localStorage['collections'] ? JSON.parse(localStorage['collections']) : [] myCollections = allCollections.find((c) => Object.keys(c)[0] === wallet.address) myCollectionList = myCollections ? Object.values(myCollections)[0] : [] console.log(localStorage['collections']) } const renderTable = useCallback(() => { return (
{myCollectionList.length > 0 && ( {myCollectionList.map((collection, index) => { return ( ) })}
Collection Name Contract Address Creation Time
Cover
{collection.name}
{collection.address} {/*
*/} {/* */}
{new Date(collection.time).toDateString()}
)}
) }, [clearFlag, wallet.address]) const clearMyCollections = () => { console.log('Cleared!') if (typeof localStorage !== 'undefined') { localStorage['collections'] = JSON.stringify(allCollections.filter((c) => Object.keys(c)[0] !== wallet.address)) myCollectionList = [] setClearFlag(!clearFlag) } } return (

{renderTable()}

{myCollectionList.length > 0 && } You haven't created any collections so far.
) } export default withMetadata(CollectionList, { center: false })