import { CollectionActions } from 'components/collections/actions/Action' import { CollectionQueries } from 'components/collections/queries/Queries' import { ContractPageHeader } from 'components/ContractPageHeader' import { AddressInput } from 'components/forms/FormInput' import { useInputState } from 'components/forms/FormInput.hooks' import { useContracts } from 'contexts/contracts' import { useWallet } from 'contexts/wallet' import type { NextPage } from 'next' import { useRouter } from 'next/router' import { NextSeo } from 'next-seo' import { useEffect, useMemo, useState } from 'react' import { withMetadata } from 'utils/layout' import { links } from 'utils/links' const CollectionActionsPage: NextPage = () => { const { minter: minterContract, sg721: sg721Contract } = useContracts() const wallet = useWallet() const [action, setAction] = useState(false) const sg721ContractState = useInputState({ id: 'sg721-contract-address', name: 'sg721-contract-address', title: 'Sg721 Address', subtitle: 'Address of the Sg721 contract', }) const minterContractState = useInputState({ id: 'minter-contract-address', name: 'minter-contract-address', title: 'Minter Address', subtitle: 'Address of the Minter contract', }) const minterMessages = useMemo( () => minterContract?.use(minterContractState.value), [minterContract, minterContractState.value], ) const sg721Messages = useMemo( () => sg721Contract?.use(sg721ContractState.value), [sg721Contract, sg721ContractState.value], ) const sg721ContractAddress = sg721ContractState.value const minterContractAddress = minterContractState.value const router = useRouter() useEffect(() => { if (minterContractAddress.length > 0 && sg721ContractAddress.length === 0) { void router.replace({ query: { minterContractAddress } }) } if (sg721ContractAddress.length > 0 && minterContractAddress.length === 0) { void router.replace({ query: { sg721ContractAddress } }) } if (sg721ContractAddress.length > 0 && minterContractAddress.length > 0) { void router.replace({ query: { sg721ContractAddress, minterContractAddress } }) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [sg721ContractAddress, minterContractAddress]) useEffect(() => { const initialMinter = new URL(document.URL).searchParams.get('minterContractAddress') const initialSg721 = new URL(document.URL).searchParams.get('sg721ContractAddress') if (initialMinter && initialMinter.length > 0) minterContractState.onChange(initialMinter) if (initialSg721 && initialSg721.length > 0) sg721ContractState.onChange(initialSg721) }, []) return (
{ setAction(false) }} type="radio" value="false" />
{ setAction(true) }} type="radio" value="true" />
{(action && ( )) || ( )}
) } export default withMetadata(CollectionActionsPage, { center: false })