Add wallet connection check for collection retrieval

This commit is contained in:
Serkan Reis 2023-01-05 13:31:48 +03:00
parent 2ad0d893c6
commit 950d5d46c8

View File

@ -124,6 +124,9 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
setMyBaseMinterContracts([]) setMyBaseMinterContracts([])
existingBaseMinterState.onChange('') existingBaseMinterState.onChange('')
void displayToast() void displayToast()
} else if (baseMinterAcquisitionMethod === 'new' || !wallet.initialized) {
setMyBaseMinterContracts([])
existingBaseMinterState.onChange('')
} }
}, [debouncedWalletAddress, baseMinterAcquisitionMethod]) }, [debouncedWalletAddress, baseMinterAcquisitionMethod])
@ -134,7 +137,7 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
} }
onChange(data) onChange(data)
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [existingBaseMinterState.value, baseMinterAcquisitionMethod]) }, [existingBaseMinterState.value, baseMinterAcquisitionMethod, wallet.initialized])
return ( return (
<div className="mx-10 mb-4 rounded border-2 border-white/20"> <div className="mx-10 mb-4 rounded border-2 border-white/20">
@ -184,7 +187,7 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
<div className={clsx('my-4 mx-10')}> <div className={clsx('my-4 mx-10')}>
<Conditional test={myBaseMinterContracts.length !== 0}> <Conditional test={myBaseMinterContracts.length !== 0}>
<select <select
className="mt-4 w-full max-w-3xl text-sm bg-white/10 select select-bordered" className="mt-4 w-full max-w-3xl text-base bg-white/10 select select-bordered"
onChange={(e) => { onChange={(e) => {
existingBaseMinterState.onChange(e.target.value.slice(e.target.value.indexOf('stars1'))) existingBaseMinterState.onChange(e.target.value.slice(e.target.value.indexOf('stars1')))
e.preventDefault() e.preventDefault()
@ -198,16 +201,23 @@ export const BaseMinterDetails = ({ onChange, minterType }: BaseMinterDetailsPro
</Conditional> </Conditional>
<Conditional test={myBaseMinterContracts.length === 0}> <Conditional test={myBaseMinterContracts.length === 0}>
<div className="flex flex-col"> <div className="flex flex-col">
<Alert className="my-2 w-[90%]" type="info"> <Conditional test={wallet.initialized}>
No previous 1/1 collections were found. You may create a new 1/1 collection or fill in the minter <Alert className="my-2 w-[90%]" type="info">
contract address manually. No previous 1/1 collections were found. You may create a new 1/1 collection or fill in the minter
</Alert> contract address manually.
<TextInput </Alert>
className="w-3/5" <TextInput
defaultValue={existingBaseMinterState.value} className="w-3/5"
{...existingBaseMinterState} defaultValue={existingBaseMinterState.value}
isRequired {...existingBaseMinterState}
/> isRequired
/>
</Conditional>
<Conditional test={!wallet.initialized}>
<Alert className="my-2 w-[90%]" type="warning">
Please connect your wallet first.
</Alert>
</Conditional>
</div> </div>
</Conditional> </Conditional>
</div> </div>