import clsx from 'clsx' import { Button } from 'components/Button' import { FormControl } from 'components/FormControl' import { FormGroup } from 'components/FormGroup' import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks' import { InputDateTime } from 'components/InputDateTime' import type { ChangeEvent } from 'react' import React, { useState } from 'react' import useCollapse from 'react-collapsed' import { toast } from 'react-hot-toast' import { useMutation } from 'react-query' import { Conditional } from './Conditional' import { NumberInput, TextInput } from './forms/FormInput' import { JsonPreview } from './JsonPreview' import { WhitelistUpload } from './WhitelistUpload' export const CollectionInfo = () => { const { getCollapseProps, getToggleProps } = useCollapse() const [timestamp, setTimestamp] = useState() const toggleProps = getToggleProps() const collapseProps = getCollapseProps() const [wlstartDate, setwlStartDate] = useState(undefined) const [wlendDate, setwlEndDate] = useState(undefined) const [whitelistArray, setWhitelistArray] = useState([]) const [coverImage, setCoverImage] = useState(null) const nameState = useInputState({ id: 'name', name: 'name', title: 'Name', subtitle: '', }) const descriptionState = useInputState({ id: 'description', name: 'description', title: 'Description', subtitle: '', }) const externalImageState = useInputState({ id: 'externalImage', name: 'externalImage', title: 'External Image', subtitle: '', }) const numberOfTokensState = useNumberInputState({ id: 'numberoftokens', name: 'numberoftokens', title: 'Number Of Tokens', subtitle: '', placeholder: '100', }) const unitPriceState = useNumberInputState({ id: 'unitPrice', name: 'unitPrice', title: 'Unit Price', subtitle: '', placeholder: '100', }) const perAddressLimitState = useNumberInputState({ id: 'peraddresslimit', name: 'peraddresslimit', title: 'Per Address Limit', subtitle: '', placeholder: '1', }) const royaltyPaymentAddressState = useInputState({ id: 'royalty-payment-address', name: 'royaltyPaymentAddress', title: 'Payment Address', subtitle: 'Address to receive royalties', placeholder: 'stars1234567890abcdefghijklmnopqrstuvwxyz...', }) const royaltyShareState = useNumberInputState({ id: 'royalty-share', name: 'royaltyShare', title: 'Share Percentage', subtitle: 'Percentage of royalties to be paid', placeholder: '8', }) const wlunitPriceState = useNumberInputState({ id: 'unit-price', name: 'unitPrice', title: 'Unit Price', subtitle: 'Price of each tokens in collection', placeholder: '500', }) const wlmemberLimitState = useNumberInputState({ id: 'member-limit', name: 'memberLimit', title: 'Member Limit', subtitle: 'Limit of the whitelisted members', placeholder: '1000', }) const wlperAddressLimitState = useNumberInputState({ id: 'per-address-limit', name: 'perAddressLimit', title: 'Per Address Limit', subtitle: 'Limit of tokens per address', placeholder: '5', }) const { isLoading, mutate } = useMutation( (event: FormEvent) => { //event.preventDefault() }, { onError: (error) => { //toast.error(String(error)) }, }, ) const whitelistFileOnChange = (data: string[]) => { setWhitelistArray(data) } const selectCoverImage = (event: ChangeEvent) => { if (event.target.files === null) return toast.error('Error selecting cover image') if (event.target.files.length === 0) { setCoverImage(null) return toast.error('No files selected.') } const reader = new FileReader() reader.onload = (e) => { if (!e.target?.result) return toast.error('Error parsing file.') if (!event.target.files) return toast.error('No files selected.') const imageFile = new File([e.target.result], event.target.files[0].name, { type: 'image/jpg' }) setCoverImage(imageFile) } reader.readAsArrayBuffer(event.target.files[0]) } return (
{coverImage !== null && (
cover-preview
)}
setTimestamp(date)} value={timestamp} />
setwlStartDate(date)} value={wlstartDate} /> setwlEndDate(date)} value={wlendDate} /> 0}>
) }