Export/Import selected mint token

This commit is contained in:
Serkan Reis 2023-08-17 14:21:30 +03:00
parent 71e539a0b4
commit 58d2a4abd7
2 changed files with 11 additions and 2 deletions

View File

@ -122,6 +122,7 @@ export const MintingDetails = ({
perAddressLimitState.onChange(importedMintingDetails.perAddressLimit) perAddressLimitState.onChange(importedMintingDetails.perAddressLimit)
setTimestamp(new Date(Number(importedMintingDetails.startTime) / 1_000_000)) setTimestamp(new Date(Number(importedMintingDetails.startTime) / 1_000_000))
paymentAddressState.onChange(importedMintingDetails.paymentAddress ? importedMintingDetails.paymentAddress : '') paymentAddressState.onChange(importedMintingDetails.paymentAddress ? importedMintingDetails.paymentAddress : '')
setSelectedMintToken(tokensList.find((token) => token.id === importedMintingDetails.selectedMintToken?.id))
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedMintingDetails]) }, [importedMintingDetails])
@ -140,6 +141,7 @@ export const MintingDetails = ({
<select <select
className="py-[9px] px-4 mt-14 ml-2 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20" className="py-[9px] px-4 mt-14 ml-2 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20"
onChange={(e) => setSelectedMintToken(tokensList.find((t) => t.displayName === e.target.value))} onChange={(e) => setSelectedMintToken(tokensList.find((t) => t.displayName === e.target.value))}
value={selectedMintToken?.displayName}
> >
{vendingMinterList {vendingMinterList
.filter((minter) => minter.factoryAddress !== undefined && minter.updatable === false) .filter((minter) => minter.factoryAddress !== undefined && minter.updatable === false)

View File

@ -43,6 +43,7 @@ export const MintingDetails = ({
const [timestamp, setTimestamp] = useState<Date | undefined>() const [timestamp, setTimestamp] = useState<Date | undefined>()
const [endTimestamp, setEndTimestamp] = useState<Date | undefined>() const [endTimestamp, setEndTimestamp] = useState<Date | undefined>()
const [selectedMintToken, setSelectedMintToken] = useState<TokenInfo | undefined>(stars) const [selectedMintToken, setSelectedMintToken] = useState<TokenInfo | undefined>(stars)
const [mintingDetailsImported, setMintingDetailsImported] = useState(false)
const unitPriceState = useNumberInputState({ const unitPriceState = useNumberInputState({
id: 'unitPrice', id: 'unitPrice',
@ -77,7 +78,9 @@ export const MintingDetails = ({
} }
useEffect(() => { useEffect(() => {
void resolvePaymentAddress() if (!importedMintingDetails || (importedMintingDetails && mintingDetailsImported)) {
void resolvePaymentAddress()
}
}, [paymentAddressState.value]) }, [paymentAddressState.value])
useEffect(() => { useEffect(() => {
@ -106,11 +109,14 @@ export const MintingDetails = ({
useEffect(() => { useEffect(() => {
if (importedMintingDetails) { if (importedMintingDetails) {
unitPriceState.onChange(Number(importedMintingDetails.unitPrice)) console.log('Selected Token ID: ', importedMintingDetails.selectedMintToken?.id)
unitPriceState.onChange(Number(importedMintingDetails.unitPrice) / 1000000)
perAddressLimitState.onChange(importedMintingDetails.perAddressLimit) perAddressLimitState.onChange(importedMintingDetails.perAddressLimit)
setTimestamp(new Date(Number(importedMintingDetails.startTime) / 1_000_000)) setTimestamp(new Date(Number(importedMintingDetails.startTime) / 1_000_000))
setEndTimestamp(new Date(Number(importedMintingDetails.endTime) / 1_000_000)) setEndTimestamp(new Date(Number(importedMintingDetails.endTime) / 1_000_000))
paymentAddressState.onChange(importedMintingDetails.paymentAddress ? importedMintingDetails.paymentAddress : '') paymentAddressState.onChange(importedMintingDetails.paymentAddress ? importedMintingDetails.paymentAddress : '')
setSelectedMintToken(tokensList.find((token) => token.id === importedMintingDetails.selectedMintToken?.id))
setMintingDetailsImported(true)
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [importedMintingDetails]) }, [importedMintingDetails])
@ -123,6 +129,7 @@ export const MintingDetails = ({
<select <select
className="py-[9px] px-4 mt-14 ml-4 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20" className="py-[9px] px-4 mt-14 ml-4 placeholder:text-white/50 bg-white/10 rounded border-2 border-white/20 focus:ring focus:ring-plumbus-20"
onChange={(e) => setSelectedMintToken(tokensList.find((t) => t.displayName === e.target.value))} onChange={(e) => setSelectedMintToken(tokensList.find((t) => t.displayName === e.target.value))}
value={selectedMintToken?.displayName}
> >
{openEditionMinterList {openEditionMinterList
.filter((minter) => minter.factoryAddress !== undefined && minter.updatable === false) .filter((minter) => minter.factoryAddress !== undefined && minter.updatable === false)