Skip to content

Commit 24fc6e8

Browse files
committed
use txbutton in batchmetadata and claimable
1 parent 927a4d3 commit 24fc6e8

File tree

4 files changed

+143
-112
lines changed

4 files changed

+143
-112
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
"use client";
2-
import { Spinner } from "@/components/ui/Spinner/Spinner";
32
import {
43
Accordion,
54
AccordionContent,
65
AccordionItem,
76
AccordionTrigger,
87
} from "@/components/ui/accordion";
98
import { Alert, AlertTitle } from "@/components/ui/alert";
10-
import { Button } from "@/components/ui/button";
119
import {
1210
Form,
1311
FormControl,
@@ -20,6 +18,7 @@ import { Input } from "@/components/ui/input";
2018
import { Textarea } from "@/components/ui/textarea";
2119
import { zodResolver } from "@hookform/resolvers/zod";
2220
import { useMutation } from "@tanstack/react-query";
21+
import { TransactionButton } from "components/buttons/TransactionButton";
2322
import { useTxNotifications } from "hooks/useTxNotifications";
2423
import { CircleAlertIcon } from "lucide-react";
2524
import { useCallback } from "react";
@@ -92,6 +91,7 @@ function BatchMetadataModule(props: ModuleInstanceProps) {
9291
{...props}
9392
uploadMetadata={uploadMetadata}
9493
isOwnerAccount={!!ownerAccount}
94+
contractChainId={contract.chain.id}
9595
/>
9696
);
9797
}
@@ -100,6 +100,7 @@ export function BatchMetadataModuleUI(
100100
props: Omit<ModuleCardUIProps, "children" | "updateButton"> & {
101101
isOwnerAccount: boolean;
102102
uploadMetadata: (values: UploadMetadataFormValues) => Promise<void>;
103+
contractChainId: number;
103104
},
104105
) {
105106
return (
@@ -115,6 +116,7 @@ export function BatchMetadataModuleUI(
115116
{props.isOwnerAccount && (
116117
<UploadMetadataNFTSection
117118
uploadMetadata={props.uploadMetadata}
119+
contractChainId={props.contractChainId}
118120
/>
119121
)}
120122
{!props.isOwnerAccount && (
@@ -155,6 +157,7 @@ export function BatchMetadataModuleUI(
155157

156158
function UploadMetadataNFTSection(props: {
157159
uploadMetadata: (values: UploadMetadataFormValues) => Promise<void>;
160+
contractChainId: number;
158161
}) {
159162
const form = useForm<UploadMetadataFormValues>({
160163
resolver: zodResolver(uploadMetadataFormSchema),
@@ -252,17 +255,18 @@ function UploadMetadataNFTSection(props: {
252255
</div>
253256

254257
<div className="flex justify-end">
255-
<Button
258+
<TransactionButton
256259
size="sm"
257-
className="min-w-24 gap-2"
260+
className="min-w-24"
258261
disabled={uploadMetadataMutation.isPending}
259262
type="submit"
263+
isLoading={uploadMetadataMutation.isPending}
264+
txChainID={props.contractChainId}
265+
transactionCount={1}
266+
colorScheme="primary"
260267
>
261-
{uploadMetadataMutation.isPending && (
262-
<Spinner className="size-4" />
263-
)}
264268
Upload
265-
</Button>
269+
</TransactionButton>
266270
</div>
267271
</div>
268272
</form>

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22
import { FormFieldSetup } from "@/components/blocks/FormFieldSetup";
33
import { DatePickerWithRange } from "@/components/ui/DatePickerWithRange";
4-
import { Spinner } from "@/components/ui/Spinner/Spinner";
54
import {
65
Accordion,
76
AccordionContent,
@@ -24,6 +23,7 @@ import { Skeleton } from "@/components/ui/skeleton";
2423
import { ToolTipLabel } from "@/components/ui/tooltip";
2524
import { zodResolver } from "@hookform/resolvers/zod";
2625
import { useMutation } from "@tanstack/react-query";
26+
import { TransactionButton } from "components/buttons/TransactionButton";
2727
import { addDays, fromUnixTime } from "date-fns";
2828
import { useAllChainsData } from "hooks/chains/allChains";
2929
import { useTxNotifications } from "hooks/useTxNotifications";
@@ -220,7 +220,7 @@ function ClaimableModule(props: ModuleInstanceProps) {
220220
}}
221221
isOwnerAccount={!!ownerAccount}
222222
isErc721={isErc721}
223-
chainId={props.contract.chain.id}
223+
contractChainId={props.contract.chain.id}
224224
mintSection={{
225225
mint,
226226
}}
@@ -232,7 +232,7 @@ export function ClaimableModuleUI(
232232
props: Omit<ModuleCardUIProps, "children" | "updateButton"> & {
233233
isOwnerAccount: boolean;
234234
isErc721: boolean;
235-
chainId: number;
235+
contractChainId: number;
236236
primarySaleRecipientSection: {
237237
setPrimarySaleRecipient: (
238238
values: PrimarySaleRecipientFormValues,
@@ -272,6 +272,7 @@ export function ClaimableModuleUI(
272272
<MintNFTSection
273273
mint={props.mintSection.mint}
274274
isErc721={props.isErc721}
275+
contractChainId={props.contractChainId}
275276
/>
276277
</AccordionContent>
277278
</AccordionItem>
@@ -289,7 +290,7 @@ export function ClaimableModuleUI(
289290
}
290291
update={props.claimConditionSection.setClaimCondition}
291292
isErc721={props.isErc721}
292-
chainId={props.chainId}
293+
chainId={props.contractChainId}
293294
tokenDecimals={props.claimConditionSection.data.tokenDecimals}
294295
/>
295296
) : (
@@ -315,6 +316,7 @@ export function ClaimableModuleUI(
315316
update={
316317
props.primarySaleRecipientSection.setPrimarySaleRecipient
317318
}
319+
contractChainId={props.contractChainId}
318320
/>
319321
) : (
320322
<Skeleton className="h-[74px]" />
@@ -598,15 +600,18 @@ function ClaimConditionSection(props: {
598600
</div>
599601

600602
<div className="flex justify-end">
601-
<Button
603+
<TransactionButton
602604
size="sm"
603-
className="min-w-24 gap-2"
605+
className="min-w-24"
604606
disabled={updateMutation.isPending || !props.isOwnerAccount}
605607
type="submit"
608+
isLoading={updateMutation.isPending}
609+
txChainID={props.chainId}
610+
transactionCount={1}
611+
colorScheme="primary"
606612
>
607-
{updateMutation.isPending && <Spinner className="size-4" />}
608613
Update
609-
</Button>
614+
</TransactionButton>
610615
</div>
611616
</div>
612617
</form>{" "}
@@ -626,6 +631,7 @@ function PrimarySaleRecipientSection(props: {
626631
primarySaleRecipient: string | undefined;
627632
update: (values: PrimarySaleRecipientFormValues) => Promise<void>;
628633
isOwnerAccount: boolean;
634+
contractChainId: number;
629635
}) {
630636
const form = useForm<PrimarySaleRecipientFormValues>({
631637
resolver: zodResolver(primarySaleRecipientFormSchema),
@@ -673,15 +679,18 @@ function PrimarySaleRecipientSection(props: {
673679
<div className="h-5" />
674680

675681
<div className="flex justify-end">
676-
<Button
682+
<TransactionButton
677683
size="sm"
678684
className="min-w-24 gap-2"
679685
disabled={updateMutation.isPending || !props.isOwnerAccount}
680686
type="submit"
687+
isLoading={updateMutation.isPending}
688+
txChainID={props.contractChainId}
689+
transactionCount={1}
690+
colorScheme="primary"
681691
>
682-
{updateMutation.isPending && <Spinner className="size-4" />}
683692
Update
684-
</Button>
693+
</TransactionButton>
685694
</div>
686695
</form>{" "}
687696
</Form>
@@ -701,6 +710,7 @@ export type MintFormValues = z.infer<typeof mintFormSchema>;
701710
function MintNFTSection(props: {
702711
mint: (values: MintFormValues) => Promise<void>;
703712
isErc721: boolean;
713+
contractChainId: number;
704714
}) {
705715
const form = useForm<MintFormValues>({
706716
resolver: zodResolver(mintFormSchema),
@@ -784,15 +794,18 @@ function MintNFTSection(props: {
784794
</div>
785795

786796
<div className="flex justify-end">
787-
<Button
797+
<TransactionButton
788798
size="sm"
789799
className="min-w-24 gap-2"
790800
disabled={mintMutation.isPending}
791801
type="submit"
802+
isLoading={mintMutation.isPending}
803+
txChainID={props.contractChainId}
804+
transactionCount={1}
805+
colorScheme="primary"
792806
>
793-
{mintMutation.isPending && <Spinner className="size-4" />}
794807
Mint
795-
</Button>
808+
</TransactionButton>
796809
</div>
797810
</div>
798811
</form>

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

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ChakraProviderSetup } from "@/components/ChakraProviderSetup";
12
import { Checkbox } from "@/components/ui/checkbox";
23
import type { Meta, StoryObj } from "@storybook/react";
34
import { useMutation } from "@tanstack/react-query";
@@ -20,6 +21,9 @@ const meta = {
2021
component: Component,
2122
parameters: {
2223
layout: "centered",
24+
nextjs: {
25+
appDirectory: true,
26+
},
2327
},
2428
} satisfies Meta<typeof Component>;
2529

@@ -73,35 +77,38 @@ function Component() {
7377
version: "1.0.0",
7478
};
7579

76-
// TODO - remove ChakraProviderSetup after converting the chakra components used in BatchMetadataModuleUI
80+
// TODO - remove ChakraProviderSetup after converting the TransactionButton to tailwind+shadcn
7781
return (
7882
<ThirdwebProvider>
79-
<ErrorProvider>
80-
<div className="container flex max-w-[1150px] flex-col gap-10 py-10">
81-
<div className="flex items-center gap-5">
82-
<CheckboxWithLabel
83-
value={isOwner}
84-
onChange={setIsOwner}
85-
id="isOwner"
86-
label="Is Owner"
87-
/>
88-
</div>
83+
<ChakraProviderSetup>
84+
<ErrorProvider>
85+
<div className="container flex max-w-[1150px] flex-col gap-10 py-10">
86+
<div className="flex items-center gap-5">
87+
<CheckboxWithLabel
88+
value={isOwner}
89+
onChange={setIsOwner}
90+
id="isOwner"
91+
label="Is Owner"
92+
/>
93+
</div>
8994

90-
<BadgeContainer label="Default">
91-
<BatchMetadataModuleUI
92-
contractInfo={contractInfo}
93-
moduleAddress="0x0000000000000000000000000000000000000000"
94-
uploadMetadata={uploadMetadataStub}
95-
uninstallButton={{
96-
onClick: async () => removeMutation.mutateAsync(),
97-
isPending: removeMutation.isPending,
98-
}}
99-
isOwnerAccount={isOwner}
100-
/>
101-
</BadgeContainer>
102-
<Toaster richColors />
103-
</div>
104-
</ErrorProvider>
95+
<BadgeContainer label="Default">
96+
<BatchMetadataModuleUI
97+
contractInfo={contractInfo}
98+
moduleAddress="0x0000000000000000000000000000000000000000"
99+
uploadMetadata={uploadMetadataStub}
100+
uninstallButton={{
101+
onClick: async () => removeMutation.mutateAsync(),
102+
isPending: removeMutation.isPending,
103+
}}
104+
isOwnerAccount={isOwner}
105+
contractChainId={1}
106+
/>
107+
</BadgeContainer>
108+
<Toaster richColors />
109+
</div>
110+
</ErrorProvider>
111+
</ChakraProviderSetup>
105112
</ThirdwebProvider>
106113
);
107114
}

0 commit comments

Comments
 (0)