import { NotebookPen, Plus } from 'lucide-react'; import { useId, useState } from 'react'; import { useTranslation } from '../../i18n'; import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, } from '../shared/DialogShell'; import { TEXTAREA } from '../shared/dialogParts'; import { MAX_MEMORY_CHARS, useTripMemory } from './useTripMemory'; /** What travellers most often want minded, one tap to add each. */ const QUICK = ['vegetarian', 'kids', 'budget', 'slow', 'accessible', 'noMuseums'] as const; /** * The trip's notes for the assistant: a few lines it follows in every * suggestion on this trip, written once instead of in every question. The * common ones are a tap away; the rest is free text. */ export default function AssistantMemoryDialog({ tripId, onClose }: { tripId: number; onClose: () => void }) { const { t } = useTranslation(); const labelId = useId(); const memory = useTripMemory(tripId); const [draft, setDraft] = useState(memory.text); const [saving, setSaving] = useState(false); const add = (line: string) => setDraft((prev) => (prev.includes(line) ? prev : `${prev.trimEnd()}${prev.trim() ? '\n' : ''}${line}`)); const save = async () => { setSaving(true); const done = await memory.save(draft); setSaving(false); if (done) onClose(); }; return ( } tint={NEUTRAL_TINT} labelId={labelId} eyebrow={t('assistant.launcher.tooltip')} title={t('assistant.memory.title')} sub={t('assistant.memory.sub')} subWraps onClose={onClose} /> } footer={ {draft.length}/{MAX_MEMORY_CHARS} {t('common.cancel')} void save()}> {t(saving ? 'common.saving' : 'common.save')} } >
{QUICK.map((key, i) => { const line = t(`assistant.memory.quick.${key}`); const taken = draft.includes(line); return ( ); })}