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 ?

{t('title')}

: null} {[1, 2, 3, 4, 5].map((val) => { if (selection === 1 && val > 2) return null if (selection === 2 && val > 3) return null if (selection === 3 && val > 4) return null if (selection === 5 && val < 4) return null else return ( {selection === 1 && val === 2 ? t('showMore') : t(`${val}t`)} {selection > 1 ? ( {t(`${val}d`)} ) : null} ) })} {welcome ? ( <> {t('continue')} {welcomeSteps[selection].length > 1 ? ( <> 1 / {welcomeSteps[selection].length} ) : null} ) : null} ) } export default ControlSettings