AuctionCard Instant Sale first pass
This commit is contained in:
parent
743fcf55d0
commit
5949de6fd4
|
@ -373,7 +373,13 @@ export const AuctionCard = ({
|
|||
onClick={() => setShowBidModal(true)}
|
||||
style={{ marginTop: 20 }}
|
||||
>
|
||||
{loading ? <Spin /> : 'Place bid'}
|
||||
{loading ? (
|
||||
<Spin />
|
||||
) : auctionView.isInstantSale ? (
|
||||
'Buy Now'
|
||||
) : (
|
||||
'Place bid'
|
||||
)}
|
||||
</Button>
|
||||
))}
|
||||
|
||||
|
@ -480,9 +486,51 @@ export const AuctionCard = ({
|
|||
}
|
||||
};
|
||||
|
||||
const instantSale = async () => {
|
||||
setLoading(true);
|
||||
|
||||
// Placing a "bid" of the full amount results in a purchase to redeem.
|
||||
if (
|
||||
myPayingAccount &&
|
||||
auctionView.auctionDataExtended?.info.instantSalePrice
|
||||
) {
|
||||
await sendPlaceBid(
|
||||
connection,
|
||||
wallet,
|
||||
myPayingAccount.pubkey,
|
||||
auctionView,
|
||||
accountByMint,
|
||||
auctionView.auctionDataExtended?.info.instantSalePrice,
|
||||
);
|
||||
setShowBidModal(false);
|
||||
|
||||
// Redeem the purchase immediately.
|
||||
try {
|
||||
await sendRedeemBid(
|
||||
connection,
|
||||
wallet,
|
||||
myPayingAccount.pubkey,
|
||||
auctionView,
|
||||
accountByMint,
|
||||
prizeTrackingTickets,
|
||||
bidRedemptions,
|
||||
bids,
|
||||
// TODO: Replace with instant sale dialog
|
||||
).then(() => setShowRedeemedBidModal(true));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setShowRedemptionIssue(true);
|
||||
}
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="modal-title">Place a bid</h2>
|
||||
<h2 className="modal-title">
|
||||
{auctionView.isInstantSale ? 'Instant Sale' : 'Place a bid'}
|
||||
</h2>
|
||||
{!!gapTime && (
|
||||
<div
|
||||
className="info-content"
|
||||
|
@ -527,6 +575,7 @@ export const AuctionCard = ({
|
|||
color: 'rgba(0, 0, 0, 0.5)',
|
||||
}}
|
||||
>
|
||||
{!auctionView.isInstantSale && (
|
||||
<InputNumber
|
||||
autoFocus
|
||||
className="input"
|
||||
|
@ -545,6 +594,7 @@ export const AuctionCard = ({
|
|||
}
|
||||
placeholder="Amount in SOL"
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
|
@ -572,21 +622,24 @@ export const AuctionCard = ({
|
|||
type="primary"
|
||||
size="large"
|
||||
className="action-btn"
|
||||
onClick={placeBid}
|
||||
onClick={auctionView.isInstantSale ? instantSale : placeBid}
|
||||
disabled={
|
||||
tickSizeInvalid ||
|
||||
gapBidInvalid ||
|
||||
!myPayingAccount ||
|
||||
value === undefined ||
|
||||
value * LAMPORTS_PER_SOL < priceFloor ||
|
||||
(!auctionView.isInstantSale &&
|
||||
(value === undefined ||
|
||||
value * LAMPORTS_PER_SOL < priceFloor)) ||
|
||||
loading ||
|
||||
!accountByMint.get(QUOTE_MINT.toBase58())
|
||||
}
|
||||
>
|
||||
{loading || !accountByMint.get(QUOTE_MINT.toBase58()) ? (
|
||||
<Spin />
|
||||
) : auctionView.isInstantSale ? (
|
||||
'Confirm Purchase'
|
||||
) : (
|
||||
'Place bid'
|
||||
'Place Bid'
|
||||
)}
|
||||
</Button>
|
||||
</>
|
||||
|
|
Loading…
Reference in New Issue