Skip to content

Commit 550613c

Browse files
committed
added in resolver for mintable and txNofitications for openedition
1 parent 1b7d29a commit 550613c

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Claimable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ export function ClaimableModuleUI(
282282
}
283283

284284
const claimConditionFormSchema = z.object({
285-
tokenId: z.coerce.number().min(0, { message: "Invalid tokenId" }).optional(),
285+
tokenId: z.coerce.bigint().min(0n, { message: "Invalid tokenId" }).optional(),
286286

287287
pricePerToken: z.coerce
288288
.number()

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Mintable.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ export type UpdateFormValues = {
4545
primarySaleRecipient: string;
4646
};
4747

48-
// TODO - add form validation with zod schema for mint form
49-
5048
export type MintFormValues = NFTMetadataInputLimited & {
5149
useNextTokenId: boolean;
5250
recipient: string;
@@ -276,12 +274,22 @@ function PrimarySalesSection(props: {
276274
);
277275
}
278276

277+
const mintFormSchema = z.object({
278+
useNextTokenId: z.boolean(),
279+
supply: z.coerce.number().min(0, { message: "Invalid supply" }),
280+
customImage: z.string().optional(),
281+
customAnimationUrl: z.string().optional(),
282+
recipient: addressSchema,
283+
tokenId: z.coerce.bigint().min(0n, { message: "Invalid tokenId" }).optional(),
284+
});
285+
279286
function MintNFTSection(props: {
280287
mint: (values: MintFormValues) => Promise<void>;
281288
isErc721: boolean;
282289
isBatchMetadataInstalled: boolean;
283290
}) {
284291
const form = useForm<MintFormValues>({
292+
resolver: zodResolver(mintFormSchema),
285293
values: {
286294
useNextTokenId: false,
287295
supply: 1,

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import {
1919
import { Input } from "@/components/ui/input";
2020
import { zodResolver } from "@hookform/resolvers/zod";
2121
import { useMutation } from "@tanstack/react-query";
22+
import { useTxNotifications } from "hooks/useTxNotifications";
2223
import { CircleAlertIcon } from "lucide-react";
2324
import { useCallback } from "react";
2425
import { useForm } from "react-hook-form";
25-
import { toast } from "sonner";
2626
import { sendAndConfirmTransaction } from "thirdweb";
2727
import { OpenEditionMetadataERC721 } from "thirdweb/modules";
2828
import { z } from "zod";
@@ -124,16 +124,19 @@ function SetSharedMetadataSection(props: {
124124
reValidateMode: "onChange",
125125
});
126126

127+
const setSharedMetadataNotifications = useTxNotifications(
128+
"Successfully set shared metadata",
129+
"Failed to set shared metadata",
130+
);
131+
127132
const setSharedMetadataMutation = useMutation({
128133
mutationFn: props.setSharedMetadata,
134+
onSuccess: setSharedMetadataNotifications.onSuccess,
135+
onError: setSharedMetadataNotifications.onError,
129136
});
130137

131138
const onSubmit = async () => {
132-
const promise = setSharedMetadataMutation.mutateAsync(form.getValues());
133-
toast.promise(promise, {
134-
success: "Successfully set shared metadata",
135-
error: (error) => `Failed to set shared metadata: ${error}`,
136-
});
139+
setSharedMetadataMutation.mutateAsync(form.getValues());
137140
};
138141

139142
return (

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/Royalty.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export function RoyaltyModuleUI(
225225
}
226226

227227
const royaltyInfoFormSchema = z.object({
228-
tokenId: z.coerce.number().min(0, { message: "Invalid tokenId" }),
228+
tokenId: z.coerce.bigint().min(0n, { message: "Invalid tokenId" }),
229229
recipient: addressSchema,
230230
bps: z
231231
.string()
@@ -241,7 +241,7 @@ function RoyaltyInfoPerTokenSection(props: {
241241
const form = useForm<RoyaltyInfoFormValues>({
242242
resolver: zodResolver(royaltyInfoFormSchema),
243243
values: {
244-
tokenId: 0,
244+
tokenId: 0n,
245245
recipient: "",
246246
bps: "",
247247
},

0 commit comments

Comments
 (0)