@cross-nft-marketplace/auction-house-nft-components
Version:
NFT Media Rendering Components
34 lines (33 loc) • 4.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuctionInfo = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const PricingString_1 = require("../utils/PricingString");
const AddressView_1 = require("../components/AddressView");
const CountdownDisplay_1 = require("../components/CountdownDisplay");
const NFTDataContext_1 = require("../context/NFTDataContext");
const useMediaContext_1 = require("../context/useMediaContext");
const InfoContainer_1 = require("./InfoContainer");
const AuctionInfo = ({ className, }) => {
var _a, _b, _c;
const { nft } = (0, react_1.useContext)(NFTDataContext_1.NFTDataContext);
const { getStyles, getString } = (0, useMediaContext_1.useMediaContext)();
const AuctionInfoWrapper = ({ children, ...containerArgs }) => ((0, jsx_runtime_1.jsx)(InfoContainer_1.InfoContainer, { ...containerArgs, className: className, children: children }));
if (!nft || !nft.pricing) {
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {});
}
const auction = nft.pricing;
const reserveAuctionCommonInfo = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [((_a = auction.trasformedPricing) === null || _a === void 0 ? void 0 : _a.buyNowPrice) && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoSpacer") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullLabel"), children: getString("BUY_NOW_PRICE") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoAuctionPricing"), children: !auction.trasformedPricing.buyNowPrice ? "N/A" : ((0, jsx_runtime_1.jsx)(PricingString_1.PricingString, { pricing: auction.trasformedPricing.buyNowPrice })) })] })), auction.currencies && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoSpacer") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullLabel"), children: getString("AVAILABLE_CURRENCIES") }), (0, jsx_runtime_1.jsx)("span", { children: auction.currencies.map(cur => cur.contract.symbol).join(", ") })] }))] }));
if (auction.isLikelyHasEnded) {
const highestPreviousBid = auction.topBid;
return ((0, jsx_runtime_1.jsxs)(AuctionInfoWrapper, { className: className, titleString: "AUCTION_SOLD_FOR", children: [(0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoAuctionPricing"), children: (0, jsx_runtime_1.jsx)(PricingString_1.PricingString, { showUSD: false, pricing: highestPreviousBid.trasformedPricing }) }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoSpacer", undefined, { width: 15 }) }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullLabel"), children: getString("WINNER") }), (0, jsx_runtime_1.jsx)(AddressView_1.AddressView, { address: highestPreviousBid.bidder })] }));
}
if (!auction.isLikelyHasEnded &&
auction.expectedEndTimestamp &&
((_b = auction.trasformedPricing) === null || _b === void 0 ? void 0 : _b.currentBid)) {
return ((0, jsx_runtime_1.jsxs)(AuctionInfoWrapper, { titleString: "AUCTION_ENDS", children: [(0, jsx_runtime_1.jsx)("div", { ...getStyles("pricingAmount"), children: (0, jsx_runtime_1.jsx)(CountdownDisplay_1.CountdownDisplay, { to: auction.expectedEndTimestamp.toString() }) }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoSpacer") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullLabel"), children: getString("HIGHEST_BID") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoAuctionPricing"), children: (0, jsx_runtime_1.jsx)(PricingString_1.PricingString, { pricing: auction.trasformedPricing.currentBid.trasformedPricing }) }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoSpacer") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullLabel"), children: getString("BIDDER") }), (0, jsx_runtime_1.jsx)(AddressView_1.AddressView, { address: auction.trasformedPricing.currentBid.bidder }), reserveAuctionCommonInfo] }));
}
return ((0, jsx_runtime_1.jsx)(AuctionInfoWrapper, { titleString: "RESERVE_PRICE", children: (0, jsx_runtime_1.jsx)("div", { ...getStyles("pricingAmount"), children: ((_c = auction.trasformedPricing) === null || _c === void 0 ? void 0 : _c.reservePrice) && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoAuctionPricing"), children: (0, jsx_runtime_1.jsx)(PricingString_1.PricingString, { pricing: auction.trasformedPricing.reservePrice }) }), reserveAuctionCommonInfo, (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { ...getStyles("fullInfoSpacer") }), (0, jsx_runtime_1.jsx)("div", { ...getStyles("fullLabel"), children: getString("AUCTION_PENDING_DURATION") }), (0, jsx_runtime_1.jsx)(CountdownDisplay_1.DurationDisplay, { duration: auction.duration })] })] })) }) }));
};
exports.AuctionInfo = AuctionInfo;