From 5949de6fd4f8545716a6c035869b84d68ec3ec55 Mon Sep 17 00:00:00 2001
From: adamjeffries <896669+adamjeffries@users.noreply.github.com>
Date: Mon, 30 Aug 2021 13:39:47 -0500
Subject: [PATCH] AuctionCard Instant Sale first pass
---
.../web/src/components/AuctionCard/index.tsx | 101 +++++++++++++-----
1 file changed, 77 insertions(+), 24 deletions(-)
diff --git a/js/packages/web/src/components/AuctionCard/index.tsx b/js/packages/web/src/components/AuctionCard/index.tsx
index 52671dc..286a27e 100644
--- a/js/packages/web/src/components/AuctionCard/index.tsx
+++ b/js/packages/web/src/components/AuctionCard/index.tsx
@@ -373,7 +373,13 @@ export const AuctionCard = ({
onClick={() => setShowBidModal(true)}
style={{ marginTop: 20 }}
>
- {loading ? : 'Place bid'}
+ {loading ? (
+
+ ) : auctionView.isInstantSale ? (
+ 'Buy Now'
+ ) : (
+ 'Place bid'
+ )}
))}
@@ -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 (
<>
-
Place a bid
+
+ {auctionView.isInstantSale ? 'Instant Sale' : 'Place a bid'}
+
{!!gapTime && (
-
- value
- ? `◎ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
- : ''
- }
- placeholder="Amount in SOL"
- />
+ {!auctionView.isInstantSale && (
+
+ value
+ ? `◎ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
+ : ''
+ }
+ placeholder="Amount in SOL"
+ />
+ )}
{loading || !accountByMint.get(QUOTE_MINT.toBase58()) ? (
+ ) : auctionView.isInstantSale ? (
+ 'Confirm Purchase'
) : (
- 'Place bid'
+ 'Place Bid'
)}
>