From 0f1c4a027b7d9db60cbcc5a24a26a65f9d610b6b Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Tue, 19 Dec 2023 13:53:41 +0300 Subject: [PATCH] Add limit type selection to OE MintingDetails --- components/openEdition/MintingDetails.tsx | 98 +++++++++++++++++------ 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/components/openEdition/MintingDetails.tsx b/components/openEdition/MintingDetails.tsx index 9d18a89..0d21865 100644 --- a/components/openEdition/MintingDetails.tsx +++ b/components/openEdition/MintingDetails.tsx @@ -1,5 +1,6 @@ /* eslint-disable eslint-comments/disable-enable-pair */ /* eslint-disable no-nested-ternary */ +import { Conditional } from 'components/Conditional' import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks' @@ -15,6 +16,8 @@ import { useWallet } from 'utils/wallet' import { NumberInput, TextInput } from '../forms/FormInput' import type { UploadMethod } from './OffChainMetadataUploadDetails' +export type LimitType = 'count_limited' | 'time_limited' + interface MintingDetailsProps { onChange: (data: MintingDetailsDataProps) => void uploadMethod: UploadMethod @@ -27,9 +30,11 @@ export interface MintingDetailsDataProps { unitPrice: string perAddressLimit: number startTime: string - endTime: string + endTime?: string + tokenCountLimit?: number paymentAddress?: string selectedMintToken?: TokenInfo + limitType: LimitType } export const MintingDetails = ({ @@ -45,6 +50,7 @@ export const MintingDetails = ({ const [endTimestamp, setEndTimestamp] = useState() const [selectedMintToken, setSelectedMintToken] = useState(stars) const [mintingDetailsImported, setMintingDetailsImported] = useState(false) + const [limitType, setLimitType] = useState('time_limited') const { timezone } = useGlobalSettings() const unitPriceState = useNumberInputState({ @@ -65,6 +71,14 @@ export const MintingDetails = ({ placeholder: '1', }) + const tokenCountLimitState = useNumberInputState({ + id: 'tokencountlimit', + name: 'tokencountlimit', + title: 'Maximum Token Count', + subtitle: 'Total number of mintable tokens', + placeholder: '100', + }) + const paymentAddressState = useInputState({ id: 'payment-address', name: 'paymentAddress', @@ -97,6 +111,8 @@ export const MintingDetails = ({ endTime: endTimestamp ? (endTimestamp.getTime() * 1_000_000).toString() : '', paymentAddress: paymentAddressState.value.trim(), selectedMintToken, + limitType, + tokenCountLimit: limitType === 'count_limited' ? tokenCountLimitState.value : undefined, } onChange(data) // eslint-disable-next-line react-hooks/exhaustive-deps @@ -107,6 +123,8 @@ export const MintingDetails = ({ endTimestamp, paymentAddressState.value, selectedMintToken, + tokenCountLimitState.value, + limitType, ]) useEffect(() => { @@ -168,30 +186,60 @@ export const MintingDetails = ({ } /> - - - setEndTimestamp( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) - } - value={ - timezone === 'Local' - ? endTimestamp - : endTimestamp - ? new Date(endTimestamp.getTime() + new Date().getTimezoneOffset() * 60 * 1000) - : undefined - } - /> - +
+

Limit Type:

+ + +
+ + + + setEndTimestamp( + timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + } + value={ + timezone === 'Local' + ? endTimestamp + : endTimestamp + ? new Date(endTimestamp.getTime() + new Date().getTimezoneOffset() * 60 * 1000) + : undefined + } + /> + + + + +