import { BedDouble, Clock, type LucideIcon, MapPin, Ticket, TriangleAlert, X } from 'lucide-react'; import { useEffect, useState } from 'react'; import { useNetworkMode } from '../../hooks/useNetworkMode'; import { useTranslation } from '../../i18n'; import Tooltip from '../shared/Tooltip'; import type { HintRule } from './assistantHintRules'; import type { AssistantHintsView, ReadyHint } from './useAssistantHints'; /** Rows shown before "n more", so the suggestions under them stay in view. */ export const MAX_VISIBLE_HINTS = 3; /** Warnings all carry the one triangle; a note says what it is about. */ const NOTE_ICONS: Partial> = { gap: Clock, longLeg: MapPin, noStay: BedDouble, unplacedBooking: Ticket, }; /** * The plan hints in the empty chat: a short, quiet list, at most three rows * with the rest behind "n more". A row is the button: it puts its day or * places in focus and asks its question. Each can be waved away. On the * desktop the X shows on hover or focus, on the phone always, with room for * a thumb. Shown means seen, so the launcher stops pointing at them. */ export default function AssistantHints({ view, phone }: { view: AssistantHintsView; phone: boolean }) { const { t } = useTranslation(); const { offline } = useNetworkMode(); const [expanded, setExpanded] = useState(false); const shown = expanded ? view.hints : view.hints.slice(0, MAX_VISIBLE_HINTS); const rest = view.hints.length - shown.length; const shownIds = shown.map((h) => h.id).join('\n'); const { markSeen } = view; useEffect(() => { if (shownIds) markSeen(shownIds.split('\n')); }, [shownIds, markSeen]); if (view.hints.length === 0) return null; return (

{t('assistant.hint.title')}

{rest > 0 && ( )}
); } function HintRow({ hint, phone, disabled, view, }: { hint: ReadyHint; phone: boolean; disabled: boolean; view: AssistantHintsView; }) { const { t } = useTranslation(); const warn = hint.level === 'warn'; const Icon = warn ? TriangleAlert : (NOTE_ICONS[hint.rule] ?? Clock); const dismissLabel = t('assistant.hint.dismiss'); return (
  • {/* Hidden until hover only where there is hover: a touch screen at window size shows it always. */}
  • ); }