// Hooks import { useState } from 'react' import { useTranslation } from 'next-i18next' import { useBackend } from 'site/hooks/useBackend.mjs' import { useToast } from 'site/hooks/useToast.mjs' // Components import { Choice, Icons, welcomeSteps, BackToAccountButton } from './shared.mjs' import { ContinueButton } from 'site/components/buttons/continue-button.mjs' export const ns = ['account', 'toast'] export const CompareSettings = ({ app, title = false, welcome = false }) => { const backend = useBackend(app) const toast = useToast() const { t } = useTranslation(ns) const [selection, setSelection] = useState(app.account?.compare ? 'yes' : 'no') const update = async (val) => { if (val !== selection) { app.startLoading() const result = await backend.updateAccount({ compare: val === 'yes' ? true : false }) if (result === true) { setSelection(val) toast.for.settingsSaved() } else toast.for.backendError() app.stopLoading() } } const nextHref = welcomeSteps[app.account?.control].length > 3 ? '/welcome/' + welcomeSteps[app.account?.control][4] : '/docs/guide' return ( <> {title ?

{t('compareTitle')}

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