// Hooks import { useState } from 'react' import { useTranslation } from 'next-i18next' import { useBackend } from 'site/hooks/useBackend.mjs' import { useToast } from 'site/hooks/useToast.mjs' // Verification methods import { validateEmail, validateTld } from 'site/utils.mjs' // Components import { BackToAccountButton } from './shared.mjs' import { Popout } from 'shared/components/popout.mjs' export const ns = ['account', 'toast'] export const EmailSettings = ({ app, title = false }) => { const backend = useBackend(app) const { t } = useTranslation(ns) const toast = useToast() const [email, setEmail] = useState(app.account.email) const [changed, setChanged] = useState(false) const save = async () => { const result = await backend.updateAccount({ email }) if (result) toast.for.settingsSaved() else toast.for.backendError() setChanged(true) } const valid = (validateEmail(email) && validateTld(email)) || false return ( <> {title ?
{t('emailChangeConfirmation')}