Skip to content

Commit fd1979f

Browse files
committed
add tx button in open edition module
1 parent d82a9fd commit fd1979f

File tree

2 files changed

+48
-37
lines changed

2 files changed

+48
-37
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.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";
@@ -73,6 +72,7 @@ function OpenEditionMetadataModule(props: ModuleInstanceProps) {
7372
{...props}
7473
setSharedMetadata={setSharedMetadata}
7574
isOwnerAccount={!!props.ownerAccount}
75+
contractChainId={props.contract.chain.id}
7676
/>
7777
);
7878
}
@@ -81,6 +81,7 @@ export function OpenEditionMetadataModuleUI(
8181
props: Omit<ModuleCardUIProps, "children" | "updateButton"> & {
8282
isOwnerAccount: boolean;
8383
setSharedMetadata: (values: SetSharedMetadataFormValues) => Promise<void>;
84+
contractChainId: number;
8485
},
8586
) {
8687
return (
@@ -95,6 +96,7 @@ export function OpenEditionMetadataModuleUI(
9596
{props.isOwnerAccount && (
9697
<SetSharedMetadataSection
9798
setSharedMetadata={props.setSharedMetadata}
99+
contractChainId={props.contractChainId}
98100
/>
99101
)}
100102
{!props.isOwnerAccount && (
@@ -115,6 +117,7 @@ export function OpenEditionMetadataModuleUI(
115117

116118
function SetSharedMetadataSection(props: {
117119
setSharedMetadata: (values: SetSharedMetadataFormValues) => Promise<void>;
120+
contractChainId: number;
118121
}) {
119122
const form = useForm<SetSharedMetadataFormValues>({
120123
resolver: zodResolver(setSharedMetadataFormSchema),
@@ -204,17 +207,18 @@ function SetSharedMetadataSection(props: {
204207
</div>
205208

206209
<div className="flex justify-end">
207-
<Button
210+
<TransactionButton
208211
size="sm"
209-
className="min-w-24 gap-2"
212+
className="min-w-24"
210213
disabled={setSharedMetadataMutation.isPending}
211214
type="submit"
215+
isLoading={setSharedMetadataMutation.isPending}
216+
colorScheme="primary"
217+
transactionCount={1}
218+
txChainID={props.contractChainId}
212219
>
213-
{setSharedMetadataMutation.isPending && (
214-
<Spinner className="size-4" />
215-
)}
216220
Update
217-
</Button>
221+
</TransactionButton>
218222
</div>
219223
</div>
220224
</form>

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

Lines changed: 36 additions & 29 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";
@@ -15,6 +16,9 @@ const meta = {
1516
component: Component,
1617
parameters: {
1718
layout: "centered",
19+
nextjs: {
20+
appDirectory: true,
21+
},
1822
},
1923
} satisfies Meta<typeof Component>;
2024

@@ -58,38 +62,41 @@ function Component() {
5862

5963
return (
6064
<ThirdwebProvider>
61-
<div className="container flex max-w-[1150px] flex-col gap-10 py-10">
62-
<div className="flex gap-2">
63-
<Checkbox
64-
id="terms1"
65-
checked={isOwner}
66-
onCheckedChange={(v) => setIsOwner(!!v)}
67-
/>
68-
<div className="grid gap-1.5 leading-none">
69-
<label
70-
htmlFor="terms1"
71-
className="font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
72-
>
73-
Is Owner
74-
</label>
65+
<ChakraProviderSetup>
66+
<div className="container flex max-w-[1150px] flex-col gap-10 py-10">
67+
<div className="flex gap-2">
68+
<Checkbox
69+
id="terms1"
70+
checked={isOwner}
71+
onCheckedChange={(v) => setIsOwner(!!v)}
72+
/>
73+
<div className="grid gap-1.5 leading-none">
74+
<label
75+
htmlFor="terms1"
76+
className="font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
77+
>
78+
Is Owner
79+
</label>
80+
</div>
7581
</div>
76-
</div>
7782

78-
<BadgeContainer label="Default">
79-
<OpenEditionMetadataModuleUI
80-
contractInfo={contractInfo}
81-
moduleAddress="0x0000000000000000000000000000000000000000"
82-
setSharedMetadata={setSharedMetadataStub}
83-
uninstallButton={{
84-
onClick: async () => removeMutation.mutateAsync(),
85-
isPending: removeMutation.isPending,
86-
}}
87-
isOwnerAccount={isOwner}
88-
/>
89-
</BadgeContainer>
83+
<BadgeContainer label="Default">
84+
<OpenEditionMetadataModuleUI
85+
contractInfo={contractInfo}
86+
moduleAddress="0x0000000000000000000000000000000000000000"
87+
setSharedMetadata={setSharedMetadataStub}
88+
uninstallButton={{
89+
onClick: async () => removeMutation.mutateAsync(),
90+
isPending: removeMutation.isPending,
91+
}}
92+
isOwnerAccount={isOwner}
93+
contractChainId={1}
94+
/>
95+
</BadgeContainer>
9096

91-
<Toaster richColors />
92-
</div>
97+
<Toaster richColors />
98+
</div>
99+
</ChakraProviderSetup>
93100
</ThirdwebProvider>
94101
);
95102
}

0 commit comments

Comments
 (0)