From fbab97e7f2320e7e4ef254adb960cdf9bdbc0f2f Mon Sep 17 00:00:00 2001 From: saml33 Date: Thu, 24 Aug 2023 13:38:33 +1000 Subject: [PATCH] add content to nft offers modal --- components/nftMarket/AssetBidsModal.tsx | 81 ++++++++++++++++++------- components/nftMarket/ListingsView.tsx | 3 +- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/components/nftMarket/AssetBidsModal.tsx b/components/nftMarket/AssetBidsModal.tsx index 56237dbe..d26948ae 100644 --- a/components/nftMarket/AssetBidsModal.tsx +++ b/components/nftMarket/AssetBidsModal.tsx @@ -7,10 +7,14 @@ import { } from 'hooks/market/useAuctionHouse' import { toUiDecimals } from '@blockworks-foundation/mango-v4' import { MANGO_MINT_DECIMALS } from 'utils/governance/constants' -import Button from '@components/shared/Button' import metaplexStore from '@store/metaplexStore' import { LazyBid, Listing, PublicBid } from '@metaplex-foundation/js' import { useTranslation } from 'next-i18next' +import EmptyState from './EmptyState' +import dayjs from 'dayjs' +import NftMarketButton from './NftMarketButton' +import Loading from '@components/shared/Loading' +import { useState } from 'react' const AssetBidsModal = ({ isOpen, @@ -18,6 +22,7 @@ const AssetBidsModal = ({ listing, }: ModalProps & { listing: Listing }) => { const { t } = useTranslation(['nft-market']) + const [accepting, setAccepting] = useState('') const metaplex = metaplexStore((s) => s.metaplex) const { data: auctionHouse } = useAuctionHouse() const { data: lazyBids, refetch: reftechBids } = useBids() @@ -27,32 +32,64 @@ const AssetBidsModal = ({ ) const acceptBid = async (lazyBid: LazyBid) => { - const bid = await metaplex!.auctionHouse().loadBid({ - lazyBid, - loadJsonMetadata: true, - }) + setAccepting(lazyBid.metadataAddress.toString()) + try { + const bid = await metaplex!.auctionHouse().loadBid({ + lazyBid, + loadJsonMetadata: true, + }) - await metaplex!.auctionHouse().sell({ - auctionHouse: auctionHouse!, - bid: bid as PublicBid, - sellerToken: listing.asset.token, - }) - refetchLazyListings() - reftechBids() + await metaplex!.auctionHouse().sell({ + auctionHouse: auctionHouse!, + bid: bid as PublicBid, + sellerToken: listing.asset.token, + }) + refetchLazyListings() + reftechBids() + } catch (e) { + console.log('error accepting offer', e) + } finally { + setAccepting('') + } } return ( -
- {assetBids?.map((x) => ( -

-

{x.createdAt.toNumber()}
-
{toUiDecimals(x.price.basisPoints, MANGO_MINT_DECIMALS)}
-
- -
-

- ))} +
+

Offers

+
+ {assetBids && assetBids.length ? ( + assetBids.map((x) => ( +
+
+

+ {dayjs(x.createdAt.toNumber()).format('DD MMM YY h:mma')} +

+ + {toUiDecimals(x.price.basisPoints, MANGO_MINT_DECIMALS)}{' '} + MNGO + +
+ + ) : ( + t('accept') + ) + } + colorClass="error" + onClick={() => acceptBid(x)} + /> +
+ )) + ) : ( + + )} +
) diff --git a/components/nftMarket/ListingsView.tsx b/components/nftMarket/ListingsView.tsx index e928eb1e..6bf556b0 100644 --- a/components/nftMarket/ListingsView.tsx +++ b/components/nftMarket/ListingsView.tsx @@ -22,7 +22,7 @@ import Loading from '@components/shared/Loading' import SheenLoader from '@components/shared/SheenLoader' import EmptyState from './EmptyState' -const filter = [ALL_FILTER, 'My Listings'] +const filter = [ALL_FILTER, 'Your Listings'] const ListingsView = () => { const { publicKey } = useWallet() @@ -96,7 +96,6 @@ const ListingsView = () => { // } const loading = loadingListings || fetchingListings - console.log(listings?.results) return (