import { ModalProps } from '../../types/modal' import Modal from '../shared/Modal' import { useState, useCallback } from 'react' import Input from '@components/forms/Input' import Label from '@components/forms/Label' import Button, { LinkButton } from '@components/shared/Button' import { MANGO_MINT_DECIMALS } from 'utils/governance/constants' import { Listing, PublicKey, token } from '@metaplex-foundation/js' import metaplexStore from '@store/metaplexStore' import { useAuctionHouse, useBids } from 'hooks/market/useAuctionHouse' import { ImgWithLoader } from '@components/ImgWithLoader' // import { useTranslation } from 'next-i18next' import { toUiDecimals } from '@blockworks-foundation/mango-v4' import Loading from '@components/shared/Loading' type ListingModalProps = { listing?: Listing } & ModalProps const BidNftModal = ({ isOpen, onClose, listing }: ListingModalProps) => { const metaplex = metaplexStore((s) => s.metaplex) const { data: auctionHouse } = useAuctionHouse() const { refetch } = useBids() // const { t } = useTranslation(['nft-market']) const noneListedAssetMode = !listing const [bidPrice, setBidPrice] = useState('') const [assetMint, setAssetMint] = useState('') const [submittingOffer, setSubmittingOffer] = useState(false) const bid = useCallback(async () => { setSubmittingOffer(true) try { await metaplex!.auctionHouse().bid({ auctionHouse: auctionHouse!, price: token(bidPrice, MANGO_MINT_DECIMALS), mintAccount: noneListedAssetMode ? new PublicKey(assetMint) : listing!.asset.mint.address, }) onClose() refetch() } catch (e) { console.log('error making offer', e) } finally { setSubmittingOffer(false) } }, [ metaplex, auctionHouse, bidPrice, noneListedAssetMode, assetMint, listing, onClose, refetch, setSubmittingOffer, ]) return (

Make an Offer

{listing ? ( ) : ( <>
) } export default BidNftModal