// Context import { LoadingStatusContext } from 'shared/context/loading-status-context.mjs' // Hooks import { useState, useContext } from 'react' import { useTranslation } from 'next-i18next' import { useAccount } from 'shared/hooks/use-account.mjs' import { useBackend } from 'shared/hooks/use-backend.mjs' // Components import { Icons, welcomeSteps, BackToAccountButton, NumberBullet } from './shared.mjs' import { ContinueButton } from 'shared/components/buttons/continue-button.mjs' import { ListInput } from 'shared/components/inputs.mjs' import { DynamicMdx } from 'shared/components/mdx/dynamic.mjs' export const ns = ['account', 'status'] export const ImperialSettings = ({ welcome = false }) => { // Hooks const { account, setAccount } = useAccount() const { setLoadingStatus } = useContext(LoadingStatusContext) const backend = useBackend() const { t, i18n } = useTranslation(ns) // State const [selection, setSelection] = useState(account?.imperial === true ? 'imperial' : 'metric') // Helper method to update account const update = async (val) => { if (val !== selection) { setLoadingStatus([true, 'processingUpdate']) const result = await backend.updateAccount({ imperial: val === 'imperial' ? true : false }) if (result.success) { setAccount(result.data.account) setSelection(val) setLoadingStatus([true, 'settingsSaved', true, true]) } else setLoadingStatus([true, 'backendError', true, true]) } } // Next step in the onboarding const nextHref = welcomeSteps[account?.control].length > 3 ? '/welcome/' + welcomeSteps[account?.control][3] : '/docs/about/guide' return (