Skip to content

Commit cab83fb

Browse files
committed
[Dashboard] Fix single lazy mint form (#4441)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR adds functionality to upload images and animations for lazy minting NFTs in the `LazyMintNftForm` component. ### Detailed summary - Added `upload` import from `thirdweb/storage`. - Modified form submission to upload image and animation URLs. - Updated data handling for image and animation URLs. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 232ce67 commit cab83fb

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

apps/dashboard/src/contract-ui/tabs/nfts/components/lazy-mint-form.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { thirdwebClient } from "@/constants/client";
12
import {
23
Accordion,
34
AccordionButton,
@@ -27,6 +28,7 @@ import type { ThirdwebContract } from "thirdweb";
2728
import { lazyMint as lazyMint721 } from "thirdweb/extensions/erc721";
2829
import { lazyMint as lazyMint1155 } from "thirdweb/extensions/erc1155";
2930
import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
31+
import { upload } from "thirdweb/storage";
3032
import {
3133
Button,
3234
FormErrorMessage,
@@ -142,23 +144,36 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
142144
return (
143145
<>
144146
<DrawerHeader>
145-
<Heading>"Mint NFT"</Heading>
147+
<Heading>Mint NFT</Heading>
146148
</DrawerHeader>
147149
<DrawerBody>
148150
<Stack
149151
spacing={6}
150152
as="form"
151153
id={LAZY_MINT_FORM_ID}
152-
onSubmit={handleSubmit((data) => {
154+
onSubmit={handleSubmit(async (data) => {
153155
if (!address) {
154156
onError("Please connect your wallet to mint.");
155157
return;
156158
}
157-
159+
let imageUri = "";
160+
if (data.image) {
161+
imageUri = await upload({
162+
client: thirdwebClient,
163+
files: [data.image],
164+
});
165+
}
166+
let animationUri = "";
167+
if (data.animation_url) {
168+
animationUri = await upload({
169+
client: thirdwebClient,
170+
files: [data.animation_url],
171+
});
172+
}
158173
const dataWithCustom = {
159174
...data,
160-
image: data.image || data.customImage,
161-
animation_url: data.animation_url || data.customAnimationUrl,
175+
image: imageUri || data.customImage,
176+
animation_url: animationUri || data.customAnimationUrl,
162177
};
163178

164179
trackEvent({

0 commit comments

Comments
 (0)