Market page

Now that we have the BuyDialog, we can include it in the market page.

Create ./pages/market.tsx exporting a Market component.

It will load all active listings from the corresponding context, and display them in a table.

The states and contexts:

const { account } = useWalletContext()
  const {
    isApproved,
    listings,
    approve,
    revoke,
    remove_listing,
    fetchMarketplaceApproval,
    fetchListings,
  } = useMarketProviderContext()
  const { tokenInfo } = useTzombiesContext()
  const { ipfsUriToGateway } = useMetadataContext()

  const [buySale, setBuySale] = useState<Listing>()
  const [loading, setLoading] = useState<boolean>(false)
  const [error, setError] = useState<string>()

There are callbacks for approve, revoke, buy and remove_listing. They all call their respective context methods, and are wrapped into error handling syntax.

The actual Market component render:

Last updated