Skip to content

Commit

Permalink
show inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
levicook committed Sep 29, 2021
1 parent 4abab0f commit 7e9dc08
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ const Home = (props: HomeProps) => {
const [isSoldOut, setIsSoldOut] = useState(false); // true when items remaining is zero
const [isMinting, setIsMinting] = useState(false); // true when user got to press MINT

const [itemsAvailable, setItemsAvailable] = useState(0);
const [itemsRedeemed, setItemsRedeemed] = useState(0);
const [itemsRemaining, setItemsRemaining] = useState(0);

const [alertState, setAlertState] = useState<AlertState>({
open: false,
message: "",
Expand Down Expand Up @@ -132,12 +136,21 @@ const Home = (props: HomeProps) => {
(async () => {
if (!wallet) return;

const { candyMachine, goLiveDate, itemsRemaining } =
await getCandyMachineState(
wallet as anchor.Wallet,
props.candyMachineId,
props.connection
);
const {
candyMachine,
goLiveDate,
itemsAvailable,
itemsRemaining,
itemsRedeemed,
} = await getCandyMachineState(
wallet as anchor.Wallet,
props.candyMachineId,
props.connection
);

setItemsAvailable(itemsAvailable);
setItemsRemaining(itemsRemaining);
setItemsRedeemed(itemsRedeemed);

setIsSoldOut(itemsRemaining === 0);
setStartDate(goLiveDate);
Expand All @@ -151,9 +164,13 @@ const Home = (props: HomeProps) => {
<p>Address: {shortenAddress(wallet.publicKey.toBase58() || "")}</p>
)}

{wallet && (
<p>Balance: {(balance || 0).toLocaleString()} SOL</p>
)}
{wallet && <p>Balance: {(balance || 0).toLocaleString()} SOL</p>}

{wallet && <p>Total Available: {itemsAvailable}</p>}

{wallet && <p>Redeemed: {itemsRedeemed}</p>}

{wallet && <p>Remaining: {itemsRemaining}</p>}

<MintContainer>
{!wallet ? (
Expand Down

0 comments on commit 7e9dc08

Please sign in to comment.