// Dependencies import { useState } from 'react' import { useTranslation } from 'next-i18next' // 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' // Components import Link from 'next/link' import { BackToAccountButton } from './shared.mjs' import { SaveSettingsButton } from 'site/components/buttons/save-settings-button.mjs' import { Popout } from 'shared/components/popout.mjs' import { RightIcon } from 'shared/components/icons.mjs' export const ns = ['account', 'toast'] export const PasswordSettings = ({ app, title = false, welcome = false }) => { const { account, setAccount, token } = useAccount() const backend = useBackend(token) const { t } = useTranslation(ns) const toast = useToast() const [password, setPassword] = useState('') const [reveal, setReveal] = useState(false) const save = async () => { app.startLoading() const result = await backend.updateAccount({ password }) if (result.success) { setAccount(result.data.account) toast.for.settingsSaved() } else toast.for.backendError() app.stopLoading() } return ( <> {title ?

{t('passwordTitle')}

: null}
setPassword(evt.target.value)} className="input w-full input-bordered flex flex-row" type={reveal ? 'text' : 'password'} placeholder={t('newPasswordPlaceholder')} />
{!welcome && } {!account.mfaEnabled && (
{t('mfaTipTitle')}

{t('mfaTipMsg')}

{t('mfa')}

)} ) }