// Dependencies import { useState, useEffect, useContext } from 'react' import { useTranslation } from 'next-i18next' import { DateTime } from 'luxon' import { CopyToClipboard } from 'react-copy-to-clipboard' // Hooks import { useAccount } from 'shared/hooks/use-account.mjs' import { useBackend } from 'shared/hooks/use-backend.mjs' import { useToast } from 'shared/hooks/use-toast.mjs' import { useRouter } from 'next/router' // Context import { LoadingContext } from 'shared/context/loading-context.mjs' import { ModalContext } from 'shared/context/modal-context.mjs' // Components import { BackToAccountButton, Choice } from './shared.mjs' import { Popout } from 'shared/components/popout.mjs' import { WebLink } from 'shared/components/web-link.mjs' import { CopyIcon } from 'shared/components/icons.mjs' import { Collapse } from 'shared/components/collapse.mjs' import { TrashIcon } from 'shared/components/icons.mjs' import { LeftIcon } from 'shared/components/icons.mjs' import { ModalWrapper } from 'shared/components/wrappers/modal.mjs' import Markdown from 'react-markdown' import { Tab } from './bio.mjs' export const ns = ['account', 'toast'] const NewSet = ({ t, account, setGenerate, oneAdded, backend, toast, standAlone = false }) => { // Context const { loading, startLoading, stopLoading } = useContext(LoadingContext) // Hooks const router = useRouter() // State const [name, setName] = useState('') const [notes, setNotes] = useState('') const [set, setSet] = useState(false) const [activeTab, setActiveTab] = useState('edit') // Helper method to create a new set const createSet = async () => { startLoading() const result = await backend.createSet({ name, }) if (result.success) { toast.success({t('nailedIt')}) setSet(result.data.set) oneAdded() } else toast.for.backendError() stopLoading() } // Helper method to clear inputs const clear = () => { setSet(false) setGenerate(false) } // Shared props for tabs const tabProps = { activeTab, setActiveTab, t } return (

{t('newSet')}

{t('name')}

{t('setNameDesc')}

setName(evt.target.value)} className="input w-full input-bordered flex flex-row" type="text" placeholder={'Georg Cantor'} /> {account.control > 2 ? ( <>

{t('notes')}

{t('setNotesDesc')}

{activeTab === 'edit' ? (