From d28af744a5f0e39b58099362648f681a5fd7d972 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Fri, 2 Feb 2024 13:49:47 +0300 Subject: [PATCH 1/3] Fix date cancellation issues --- .../creation/CollectionDetails.tsx | 12 ++++++----- .../collections/creation/MintingDetails.tsx | 9 +++++--- .../collections/creation/WhitelistDetails.tsx | 21 +++++++++++++------ components/openEdition/CollectionDetails.tsx | 10 ++++++--- components/openEdition/MintingDetails.tsx | 17 +++++++++------ 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/components/collections/creation/CollectionDetails.tsx b/components/collections/creation/CollectionDetails.tsx index 6e039e8..13a137f 100644 --- a/components/collections/creation/CollectionDetails.tsx +++ b/components/collections/creation/CollectionDetails.tsx @@ -192,11 +192,13 @@ export const CollectionDetails = ({ : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setTimestamp( - timezone === 'Local' - ? date - : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setTimestamp( + timezone === 'Local' + ? date + : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setTimestamp(undefined) } value={ timezone === 'Local' diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index ed44002..580ec87 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -1,4 +1,5 @@ /* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ /* eslint-disable no-nested-ternary */ import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' @@ -170,9 +171,11 @@ export const MintingDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setTimestamp( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setTimestamp( + timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setTimestamp(undefined) } value={ timezone === 'Local' diff --git a/components/collections/creation/WhitelistDetails.tsx b/components/collections/creation/WhitelistDetails.tsx index b32fcad..bfe42dc 100644 --- a/components/collections/creation/WhitelistDetails.tsx +++ b/components/collections/creation/WhitelistDetails.tsx @@ -1,4 +1,5 @@ /* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ /* eslint-disable no-nested-ternary */ import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' @@ -338,9 +339,13 @@ export const WhitelistDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setStartDate( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setStartDate( + timezone === 'Local' + ? date + : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setStartDate(undefined) } value={ timezone === 'Local' @@ -362,9 +367,13 @@ export const WhitelistDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setEndDate( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setEndDate( + timezone === 'Local' + ? date + : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setEndDate(undefined) } value={ timezone === 'Local' diff --git a/components/openEdition/CollectionDetails.tsx b/components/openEdition/CollectionDetails.tsx index 1ed1014..994cb75 100644 --- a/components/openEdition/CollectionDetails.tsx +++ b/components/openEdition/CollectionDetails.tsx @@ -236,9 +236,13 @@ export const CollectionDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setTimestamp( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setTimestamp( + timezone === 'Local' + ? date + : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setTimestamp(undefined) } value={ timezone === 'Local' diff --git a/components/openEdition/MintingDetails.tsx b/components/openEdition/MintingDetails.tsx index 9d18a89..a707321 100644 --- a/components/openEdition/MintingDetails.tsx +++ b/components/openEdition/MintingDetails.tsx @@ -1,4 +1,5 @@ /* eslint-disable eslint-comments/disable-enable-pair */ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ /* eslint-disable no-nested-ternary */ import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' @@ -155,9 +156,11 @@ export const MintingDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setTimestamp( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setTimestamp( + timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setTimestamp(undefined) } value={ timezone === 'Local' @@ -179,9 +182,11 @@ export const MintingDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - setEndTimestamp( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) + date + ? setEndTimestamp( + timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setEndTimestamp(undefined) } value={ timezone === 'Local' From ae2b565af67e65b48a650128f3ea16522c6a11aa Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Fri, 2 Feb 2024 16:23:09 +0300 Subject: [PATCH 2/3] Dictate minting start time wrt whitelist start time --- .../collections/creation/MintingDetails.tsx | 15 ++++++++++++++- .../collections/creation/WhitelistDetails.tsx | 6 +++--- pages/collections/create.tsx | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index 580ec87..e03752f 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -23,6 +23,8 @@ interface MintingDetailsProps { minimumMintPrice: number mintingTokenFromFactory?: TokenInfo importedMintingDetails?: MintingDetailsDataProps + isPresale: boolean + whitelistStartDate?: string } export interface MintingDetailsDataProps { @@ -41,6 +43,8 @@ export const MintingDetails = ({ minimumMintPrice, mintingTokenFromFactory, importedMintingDetails, + isPresale, + whitelistStartDate, }: MintingDetailsProps) => { const wallet = useWallet() const { timezone } = useGlobalSettings() @@ -130,6 +134,12 @@ export const MintingDetails = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [importedMintingDetails]) + useEffect(() => { + if (isPresale) { + setTimestamp(whitelistStartDate ? new Date(Number(whitelistStartDate) / 1_000_000) : undefined) + } + }, [whitelistStartDate, isPresale]) + return (
@@ -163,10 +173,13 @@ export const MintingDetails = ({ { { numberOfTokens={uploadDetails?.assetFiles.length} onChange={setMintingDetails} uploadMethod={uploadDetails?.uploadMethod as UploadMethod} + whitelistStartDate={whitelistDetails?.startTime} />
From 39385ee82e8e823f884d05c96377f88ce398f6eb Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Fri, 2 Feb 2024 16:34:17 +0300 Subject: [PATCH 3/3] Address lint issues --- components/openEdition/MintingDetails.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/openEdition/MintingDetails.tsx b/components/openEdition/MintingDetails.tsx index 7f9697e..7ccded2 100644 --- a/components/openEdition/MintingDetails.tsx +++ b/components/openEdition/MintingDetails.tsx @@ -229,11 +229,13 @@ export const MintingDetails = ({ timezone === 'Local' ? new Date() : new Date(Date.now() + new Date().getTimezoneOffset() * 60 * 1000) } onChange={(date) => - date - ? setEndTimestamp( - timezone === 'Local' ? date : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), - ) - : setEndTimestamp(undefined) + date + ? setEndTimestamp( + timezone === 'Local' + ? date + : new Date(date.getTime() - new Date().getTimezoneOffset() * 60 * 1000), + ) + : setEndTimestamp(undefined) } value={ timezone === 'Local'