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

{t('title')}

: null} {['yes', 'no'].map((val) => ( {selection === 1 && val === 2 ? t('showMore') : t(`${val}`)} {t(`${val}d`)} ))} {welcome ? ( <> {t('continue')} {welcomeSteps[app.account?.control].length > 0 ? ( <> 4 / {welcomeSteps[app.account?.control].length} ) : null} ) : null} ) } export default CompareSettings