From 3fbebbe03d264ca825132956d0ace32c3b7fd247 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 16 Aug 2023 17:57:07 +0300 Subject: [PATCH] Auto-add wallet address as whitelist admin --- components/collections/creation/WhitelistDetails.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/collections/creation/WhitelistDetails.tsx b/components/collections/creation/WhitelistDetails.tsx index a0de6c9..aa0d908 100644 --- a/components/collections/creation/WhitelistDetails.tsx +++ b/components/collections/creation/WhitelistDetails.tsx @@ -9,6 +9,7 @@ import { InputDateTime } from 'components/InputDateTime' import type { WhitelistFlexMember } from 'components/WhitelistFlexUpload' import { WhitelistFlexUpload } from 'components/WhitelistFlexUpload' import type { TokenInfo } from 'config/token' +import { useWallet } from 'contexts/wallet' import React, { useEffect, useState } from 'react' import { isValidAddress } from 'utils/isValidAddress' @@ -46,6 +47,8 @@ export const WhitelistDetails = ({ mintingTokenFromFactory, importedWhitelistDetails, }: WhitelistDetailsProps) => { + const wallet = useWallet() + const [whitelistState, setWhitelistState] = useState('none') const [whitelistType, setWhitelistType] = useState('standard') const [startDate, setStartDate] = useState(undefined) @@ -196,6 +199,14 @@ export const WhitelistDetails = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [importedWhitelistDetails]) + useEffect(() => { + if (whitelistState === 'new' && wallet.address) { + addressListState.reset() + addressListState.add({ address: wallet.address }) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [whitelistState, wallet.address]) + return (
@@ -344,7 +355,6 @@ export const WhitelistDetails = ({