// Dependencies import { useState } from 'react' import { useTranslation } from 'next-i18next' // Hooks import { useAccount } from 'shared/hooks/use-account.mjs' import { useBackend } from 'shared/hooks/use-backend.mjs' import { useLoadingStatus } from 'shared/hooks/use-loading-status.mjs' // Components import { Choice, Icons, welcomeSteps, BackToAccountButton } from './shared.mjs' import { ContinueButton } from 'shared/components/buttons/continue-button.mjs' export const ns = ['account', 'status'] export const CompareSettings = ({ title = false, welcome = false }) => { // Hooks const { account, setAccount } = useAccount() const backend = useBackend() const { setLoadingStatus, LoadingStatus } = useLoadingStatus() const { t } = useTranslation(ns) // State const [selection, setSelection] = useState(account?.compare ? 'yes' : 'no') // Helper method to update the account const update = async (val) => { if (val !== selection) { setLoadingStatus([true, 'processingUpdate']) const result = await backend.updateAccount({ compare: val === 'yes' ? true : false, }) if (result.success) { setLoadingStatus([true, 'settingsSaved', true, true]) setAccount(result.data.account) setSelection(val) } else setLoadingStatus([true, 'backendError', true, true]) } } // Link to the next onboarding step const nextHref = welcomeSteps[account?.control].length > 3 ? '/welcome/' + welcomeSteps[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[account?.control].length > 0 ? ( <> 4 / {welcomeSteps[account?.control].length} ) : null} ) : ( )}
) }