import { useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; import { SupportChat } from "./SupportChat"; const DISMISSED_KEY = "ns_help_bubble_dismissed"; function readDismissed(): boolean { try { return localStorage.getItem(DISMISSED_KEY) === "1"; } catch { return false; } } /** The bottom right help button. Hidden on the sign in screens. */ export function SupportWidget() { const { pathname } = useLocation(); const [open, setOpen] = useState(false); const [bubbleReady, setBubbleReady] = useState(false); const [dismissed, setDismissed] = useState(readDismissed); useEffect(() => { const t = window.setTimeout(() => setBubbleReady(true), 2500); return () => window.clearTimeout(t); }, []); if (pathname.startsWith("/auth") || pathname === "/welcome") return null; const dismiss = () => { setDismissed(true); try { localStorage.setItem(DISMISSED_KEY, "1"); } catch { /* private mode: hidden for this visit only */ } }; return ( <> {bubbleReady && !dismissed && !open && (
)} {open && setOpen(false)} />} ); }