@@ -28,25 +28,6 @@ import { useActiveAccount } from "thirdweb/react";
2828import type { Account } from "thirdweb/wallets" ;
2929import { useModuleContractInfo } from "./moduleContractInfo" ;
3030
31- function Module (
32- props : Omit < ModuleCardUIProps , "children" | "updateButton" > & {
33- name : string ;
34- contract : ContractOptions ;
35- isOwnerAccount : boolean ;
36- } ,
37- ) {
38- return < ModuleCardUI { ...props } /> ;
39- //if (props.name.includes("Transferable")) {
40- // return <TransferableModule {...props} />;
41- //}
42- //if (props.name.includes("Mintable")) {
43- // return <MintableModule {...props} />;
44- //}
45- //if (props.name.includes("BurnToRedeem")) {
46- // return <BurnToRedeemModule {...props} />;
47- //}
48- }
49-
5031type ModuleProps = {
5132 moduleAddress : string ;
5233 contract : ContractOptions ;
@@ -85,12 +66,12 @@ export function ModuleCard(props: ModuleProps) {
8566 await waitForReceipt ( txResult ) ;
8667 } ,
8768 onSuccess ( ) {
88- toast . success ( "Module Removed successfully" ) ;
69+ toast . success ( "Module uninstalled successfully" ) ;
8970 props . onRemoveModule ( ) ;
9071 } ,
9172 onError ( error ) {
92- toast . error ( "Failed to remove module" ) ;
93- console . error ( "Error during uninstallation:" , error ) ;
73+ toast . error ( "Failed to uninstall module" ) ;
74+ console . error ( error ) ;
9475 } ,
9576 } ) ;
9677
@@ -100,18 +81,16 @@ export function ModuleCard(props: ModuleProps) {
10081 return ;
10182 }
10283
103- setIsUninstallModalOpen ( false ) ;
10484 uninstallMutation . mutate ( account ) ;
10585 } ;
10686
10787 if ( ! contractInfo ) {
108- return < Skeleton className = "h-[175px ] w-full border border-border" /> ;
88+ return < Skeleton className = "h-[190px ] w-full border border-border" /> ;
10989 }
11090
11191 return (
11292 < >
113- < Module
114- name = { contractInfo . name }
93+ < ModuleCardUI
11594 contractInfo = { {
11695 name : contractInfo . name ,
11796 description : contractInfo . description ,
@@ -120,11 +99,12 @@ export function ModuleCard(props: ModuleProps) {
12099 } }
121100 isOwnerAccount = { props . isOwnerAccount }
122101 uninstallButton = { {
123- onClick : handleRemove ,
102+ onClick : ( ) => {
103+ setIsUninstallModalOpen ( true ) ;
104+ } ,
124105 isPending : uninstallMutation . isPending ,
125106 } }
126107 moduleAddress = { moduleAddress }
127- contract = { contract }
128108 />
129109
130110 < Dialog
@@ -187,11 +167,11 @@ export type ModuleCardUIProps = {
187167 moduleAddress : string ;
188168 isOwnerAccount : boolean ;
189169 uninstallButton : {
190- onClick : ( ) => Promise < void > ;
170+ onClick : ( ) => void ;
191171 isPending : boolean ;
192172 } ;
193173 updateButton ?: {
194- onClick : ( ) => Promise < void > ;
174+ onClick : ( ) => void ;
195175 isPending : boolean ;
196176 isDisabled : boolean ;
197177 } ;
@@ -278,34 +258,32 @@ export function ModuleCardUI(props: ModuleCardUIProps) {
278258 { props . children }
279259 </ >
280260 ) : null }
261+ </ div >
281262
282- < div className = "h-5" />
263+ < div className = "flex flex-row justify-end gap-3 border-border border-t p-4 lg:p-6" >
264+ < Button
265+ size = "sm"
266+ onClick = { props . uninstallButton . onClick }
267+ variant = "destructive"
268+ className = "min-w-24 gap-2"
269+ disabled = { ! props . isOwnerAccount }
270+ >
271+ { props . uninstallButton . isPending && < Spinner className = "size-4" /> }
272+ Uninstall
273+ </ Button >
283274
284- < div className = "flex flex-row justify-end gap-3 border-border border-t py-4" >
275+ { props . isOwnerAccount && props . updateButton && (
285276 < Button
286277 size = "sm"
287- onClick = { props . uninstallButton . onClick }
288- variant = "destructive"
289278 className = "min-w-24 gap-2"
290- disabled = { ! props . isOwnerAccount }
279+ type = "submit"
280+ onClick = { props . updateButton . onClick }
281+ disabled = { props . updateButton . isPending || ! props . isOwnerAccount }
291282 >
292- { props . uninstallButton . isPending && < Spinner className = "size-4" /> }
293- Uninstall
283+ { props . updateButton . isPending && < Spinner className = "size-4" /> }
284+ Update
294285 </ Button >
295-
296- { props . isOwnerAccount && props . updateButton && (
297- < Button
298- size = "sm"
299- className = "min-w-24 gap-2"
300- type = "submit"
301- onClick = { props . updateButton . onClick }
302- disabled = { props . updateButton . isPending || ! props . isOwnerAccount }
303- >
304- { props . updateButton . isPending && < Spinner className = "size-4" /> }
305- Update
306- </ Button >
307- ) }
308- </ div >
286+ ) }
309287 </ div >
310288 </ section >
311289 ) ;
0 commit comments