// Hooks import { useState } from 'react' import { useTranslation } from 'next-i18next' import { useBackend } from 'site/hooks/useBackend.mjs' import { useToast } from 'site/hooks/useToast.mjs' // Components import { Choice, Icons, welcomeSteps, BackToAccountButton } from './shared.mjs' import { ContinueButton } from 'site/components/buttons/continue-button.mjs' export const ns = ['account', 'toast'] export const ImperialSettings = ({ app, title = false, welcome = false }) => { const backend = useBackend(app) const toast = useToast() const { t } = useTranslation(ns) const [selection, setSelection] = useState(app.account?.imperial === true ? 'imperial' : 'metric') const update = async (val) => { if (val !== selection) { app.startLoading() const result = await backend.updateAccount({ imperial: val === 'imperial' ? true : false }) if (result === true) { setSelection(val) toast.for.settingsSaved() } else toast.for.backendError() app.stopLoading() } } const nextHref = welcomeSteps[app.account?.control].length > 3 ? '/welcome/' + welcomeSteps[app.account?.control][3] : '/docs/guide' return ( <> {title ?