diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-button.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-button.tsx index 67350b0083b..0f6a25d110a 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-button.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-button.tsx @@ -1,9 +1,16 @@ "use client"; +import { + Sheet, + SheetContent, + SheetHeader, + SheetTitle, + SheetTrigger, +} from "@/components/ui/sheet"; import { MinterOnly } from "@3rdweb-sdk/react/components/roles/minter-only"; -import { useDisclosure } from "@chakra-ui/react"; import { PlusIcon } from "lucide-react"; +import { useState } from "react"; import type { ThirdwebContract } from "thirdweb"; -import { Button, Drawer } from "tw-components"; +import { Button } from "tw-components"; import { LazyMintNftForm } from "./lazy-mint-form"; interface NFTLazyMintButtonProps { @@ -16,26 +23,30 @@ export const NFTLazyMintButton: React.FC = ({ isErc721, ...restButtonProps }) => { - const { isOpen, onOpen, onClose } = useDisclosure(); + const [open, setOpen] = useState(false); return ( - - - - + + + + + + + Mint NFT + + + + ); }; diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-form.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-form.tsx index 02f7b62b9ee..ea7f1b93d36 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-form.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/lazy-mint-form.tsx @@ -7,13 +7,9 @@ import { AccordionItem, AccordionPanel, Divider, - DrawerBody, - DrawerFooter, - DrawerHeader, FormControl, Input, Textarea, - useModalContext, } from "@chakra-ui/react"; import { OpenSeaPropertyBadge } from "components/badges/opensea"; import { TransactionButton } from "components/buttons/TransactionButton"; @@ -21,8 +17,9 @@ import { PropertiesFormControl } from "components/contract-pages/forms/propertie import { FileInput } from "components/shared/FileInput"; import { useTrack } from "hooks/analytics/useTrack"; import { useImageFileOrUrl } from "hooks/useImageFileOrUrl"; -import { useTxNotifications } from "hooks/useTxNotifications"; +import type { Dispatch, SetStateAction } from "react"; import { useForm } from "react-hook-form"; +import { toast } from "sonner"; import type { ThirdwebContract } from "thirdweb"; import { lazyMint as lazyMint721 } from "thirdweb/extensions/erc721"; import { lazyMint as lazyMint1155 } from "thirdweb/extensions/erc1155"; @@ -42,15 +39,17 @@ const LAZY_MINT_FORM_ID = "nft-lazy-mint-form"; type LazyMintNftFormParams = { contract: ThirdwebContract; isErc721: boolean; + setOpen: Dispatch>; }; export const LazyMintNftForm: React.FC = ({ contract, isErc721, + setOpen, }) => { const trackEvent = useTrack(); const address = useActiveAccount()?.address; - const { mutate, isPending } = useSendAndConfirmTransaction(); + const sendAndConfirmTx = useSendAndConfirmTransaction(); const { setValue, @@ -67,13 +66,6 @@ export const LazyMintNftForm: React.FC = ({ } >(); - const modalContext = useModalContext(); - const { onSuccess, onError } = useTxNotifications( - "NFT Lazy minted successfully", - "Failed to lazy mint NFT", - contract, - ); - const setFile = (file: File) => { if (file.type.includes("image")) { // image files @@ -141,19 +133,15 @@ export const LazyMintNftForm: React.FC = ({ return ( <> - - Mint NFT - - -
{ - if (!address) { - onError("Please connect your wallet to mint."); - return; - } - + { + if (!address) { + toast.error("Please connect your wallet to mint."); + return; + } + try { trackEvent({ category: "nft", action: "lazy-mint", @@ -163,15 +151,15 @@ export const LazyMintNftForm: React.FC = ({ const transaction = isErc721 ? lazyMint721({ contract, nfts }) : lazyMint1155({ contract, nfts }); - mutate(transaction, { + + const promise = sendAndConfirmTx.mutateAsync(transaction, { onSuccess: () => { trackEvent({ category: "nft", action: "lazy-mint", label: "success", }); - onSuccess(); - modalContext.onClose(); + setOpen(false); }, onError: (error) => { trackEvent({ @@ -180,154 +168,162 @@ export const LazyMintNftForm: React.FC = ({ label: "error", error, }); - onError(error); }, }); - })} - > -
- Metadata - + + toast.promise(promise, { + loading: "Lazy minting NFT", + error: "Failed to lazy mint NFT", + success: "Lazy minted successfully", + }); + } catch (err) { + console.error(err); + toast.error("Failed to lazy mint NFT"); + } + })} + > +
+ Metadata + +
+ + Name + + {errors?.name?.message} + + + Media +
+
- - Name - - {errors?.name?.message} - - - Media -
- -
+ + You can upload image, audio, video, html, text, pdf, and 3d model + files here. + + + {mediaFileError?.message as unknown as string} + +
+ {showCoverImageUpload && ( + + Cover Image + setValue("image", file)} + className="rounded border border-border transition-all" + /> - You can upload image, audio, video, html, text, pdf, and 3d model - files here. + You can optionally upload an image as the cover of your NFT. - {mediaFileError?.message as unknown as string} + {errors?.image?.message as unknown as string} - {showCoverImageUpload && ( - - Cover Image - setValue("image", file)} - className="rounded border border-border transition-all" - /> - - You can optionally upload an image as the cover of your NFT. - - - {errors?.image?.message as unknown as string} - - - )} - - Description -