diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/mint-button.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/mint-button.tsx index e5ff258a241..a868c1139fc 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/mint-button.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/mint-button.tsx @@ -1,10 +1,17 @@ "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 { NFTMintForm } from "./mint-form"; interface NFTMintButtonProps { @@ -17,26 +24,31 @@ export const NFTMintButton: 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/mint-form.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/mint-form.tsx index 71110a06bb6..0870ea98d81 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/mint-form.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/nfts/components/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 { mintTo as erc721MintTo } from "thirdweb/extensions/erc721"; import { mintTo as erc1155MintTo } from "thirdweb/extensions/erc1155"; @@ -42,9 +39,14 @@ const MINT_FORM_ID = "nft-mint-form"; type NFTMintForm = { contract: ThirdwebContract; isErc721: boolean; + setOpen: Dispatch>; }; -export const NFTMintForm: React.FC = ({ contract, isErc721 }) => { +export const NFTMintForm: React.FC = ({ + contract, + isErc721, + setOpen, +}) => { const trackEvent = useTrack(); const address = useActiveAccount()?.address; const { @@ -62,14 +64,6 @@ export const NFTMintForm: React.FC = ({ contract, isErc721 }) => { } >(); - const modalContext = useModalContext(); - - const { onSuccess, onError } = useTxNotifications( - "NFT minted successfully", - "Failed to mint NFT", - contract, - ); - const setFile = (file: File) => { if (file.type.includes("image")) { // image files @@ -135,23 +129,20 @@ export const NFTMintForm: React.FC = ({ contract, isErc721 }) => { watch("animation_url") instanceof File || watch("external_url") instanceof File; - const { mutate, isPending } = useSendAndConfirmTransaction(); + const sendAndConfirmTx = useSendAndConfirmTransaction(); 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 { const dataWithCustom = { ...data, image: data.image || data.customImage, @@ -172,15 +163,14 @@ export const NFTMintForm: React.FC = ({ contract, isErc721 }) => { nft, supply: BigInt(data.supply), }); - mutate(transaction, { + const promise = sendAndConfirmTx.mutateAsync(transaction, { onSuccess: () => { trackEvent({ category: "nft", action: "mint", label: "success", }); - onSuccess(); - modalContext.onClose(); + setOpen(false); }, // biome-ignore lint/suspicious/noExplicitAny: FIXME onError: (error: any) => { @@ -190,166 +180,174 @@ export const NFTMintForm: React.FC = ({ contract, isErc721 }) => { label: "error", error, }); - onError(error); }, }); - })} - > -
- Metadata - + + toast.promise(promise, { + loading: "Minting NFT", + success: "NFT minted successfully", + error: "Failed to mint NFT", + }); + } catch (err) { + console.error(err); + toast.error("Failed to 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 -