import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { Check } from "lucide-react"; import { saveUserPreferences } from "@/main-axios"; /** * Asks once, plainly. * * "Leave it off" is preselected and applied on mount, so someone who clicks * straight through ends up without the assistant rather than with it. Both * options are described in the same flat register and neither is marked * recommended: this is a choice, not a pitch. */ export function AiAssistantStep() { const { t } = useTranslation(); const [enabled, setEnabled] = useState(false); function apply(next: boolean) { setEnabled(next); const hidden = new Set( JSON.parse(localStorage.getItem("hiddenRailTabs") ?? "[]"), ); if (next) hidden.delete("ai"); else hidden.add("ai"); const serialized = JSON.stringify([...hidden]); localStorage.setItem("hiddenRailTabs", serialized); window.dispatchEvent(new Event("hiddenRailTabsChanged")); saveUserPreferences({ aiAssistantEnabled: next, hiddenRailTabs: serialized, }).catch(() => { // The local choice still applies if the write fails. }); } // Skipping the step entirely still has to mean off, not unset. useEffect(() => { apply(false); }, []); const options = [ { value: false, title: t("onboarding.aiSkipTitle"), description: t("onboarding.aiSkipDesc"), }, { value: true, title: t("onboarding.aiEnableTitle"), description: t("onboarding.aiEnableDesc"), }, ]; return (

{t("onboarding.aiIntro")}

{options.map((option) => ( ))}

{t("onboarding.aiNote")}

); }