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 = ['control'] export const ControlSettings = ({ app, title = false, welcome = false }) => { const backend = useBackend(app) const { t } = useTranslation(namespaces) const [selection, setSelection] = useState(app.account.control || 2) const update = async (control) => { if (control !== selection) { const result = await backend.updateAccount({ control }) if (result) setSelection(control) } } const nextHref = welcomeSteps[selection].length > 1 ? '/welcome/' + welcomeSteps[selection][1] : '/docs/guide' return ( <> {title ?