import { useState } from 'react' import { useTranslation } from 'next-i18next' import useBackend from 'site/hooks/useBackend.js' import Link from 'next/link' import { Choice, Icons, welcomeSteps } from '../shared.js' export const namespaces = ['units'] const UnitsSettings = ({ app, title = false, welcome = false }) => { const backend = useBackend(app) const { t } = useTranslation(namespaces) const [selection, setSelection] = useState(app.account?.imperial === true ? 'imperial' : 'metric') const update = async (val) => { if (val !== selection) { const result = await backend.updateAccount({ imperial: val === 'imperial' ? true : false }) if (result) setSelection(val) } } const nextHref = welcomeSteps[app.account?.control].length > 3 ? '/welcome/' + welcomeSteps[app.account?.control][3] : '/docs/guide' return ( <> {title ?