import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { IconCircle, IconCircleCheck, IconX } from "@tabler/icons-react"; import { t } from "../i18n"; export interface SetupStep { id: string; title: string; description: string; to: string; /** What to call the button that goes there. */ action: string; done: boolean; } const DISMISSED_KEY = "hlm-setup-dismissed"; export const SHOW_SETUP_EVENT = "show-setup-guide"; function wasDismissed(): boolean { try { return localStorage.getItem(DISMISSED_KEY) === "1"; } catch { return false; } } /** * A checklist for a new installation, at the top of the dashboard: what to set up, which steps are already done (worked out from * what exists, never ticked by hand), and a way to put it away. It goes by itself once everything is done. */ export default function SetupGuide({ steps }: { steps: SetupStep[] }) { const [dismissed, setDismissed] = useState(wasDismissed); // The command palette can bring it back. useEffect(() => { const show = () => { try { localStorage.removeItem(DISMISSED_KEY); } catch { // not remembered; it shows for this visit anyway } setDismissed(false); }; window.addEventListener(SHOW_SETUP_EVENT, show); return () => window.removeEventListener(SHOW_SETUP_EVENT, show); }, []); const done = steps.filter((s) => s.done).length; if (dismissed || steps.length === 0 || done === steps.length) return null; const dismiss = () => { try { localStorage.setItem(DISMISSED_KEY, "1"); } catch { // not remembered; it is gone for this visit anyway } setDismissed(true); }; return (