|
| 1 | +import { thirdwebClient } from "@/constants/client"; |
1 | 2 | import {
|
2 | 3 | Accordion,
|
3 | 4 | AccordionButton,
|
@@ -27,6 +28,7 @@ import type { ThirdwebContract } from "thirdweb";
|
27 | 28 | import { lazyMint as lazyMint721 } from "thirdweb/extensions/erc721";
|
28 | 29 | import { lazyMint as lazyMint1155 } from "thirdweb/extensions/erc1155";
|
29 | 30 | import { useActiveAccount, useSendAndConfirmTransaction } from "thirdweb/react";
|
| 31 | +import { upload } from "thirdweb/storage"; |
30 | 32 | import {
|
31 | 33 | Button,
|
32 | 34 | FormErrorMessage,
|
@@ -142,23 +144,36 @@ export const LazyMintNftForm: React.FC<LazyMintNftFormParams> = ({
|
142 | 144 | return (
|
143 | 145 | <>
|
144 | 146 | <DrawerHeader>
|
145 |
| - <Heading>"Mint NFT"</Heading> |
| 147 | + <Heading>Mint NFT</Heading> |
146 | 148 | </DrawerHeader>
|
147 | 149 | <DrawerBody>
|
148 | 150 | <Stack
|
149 | 151 | spacing={6}
|
150 | 152 | as="form"
|
151 | 153 | id={LAZY_MINT_FORM_ID}
|
152 |
| - onSubmit={handleSubmit((data) => { |
| 154 | + onSubmit={handleSubmit(async (data) => { |
153 | 155 | if (!address) {
|
154 | 156 | onError("Please connect your wallet to mint.");
|
155 | 157 | return;
|
156 | 158 | }
|
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 | + } |
158 | 173 | const dataWithCustom = {
|
159 | 174 | ...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, |
162 | 177 | };
|
163 | 178 |
|
164 | 179 | trackEvent({
|
|
0 commit comments