import { ChevronDown, ShieldCheck } from 'lucide-react'; import { useState } from 'react'; import { useTranslation } from '../../i18n'; import { useAssistantStore } from '../../store/assistantStore'; import { useToast } from '../shared/Toast'; import { useAssistantScope } from './assistantViewContext'; import { providerLabel } from './providerCatalog'; /** * Who reads along, said once. A user who connected their own provider agreed * to this while connecting; on the admin's connection the chat says it here, * above the composer, until the user has read it. A new provider set up by * the admin asks again, because the answer is stored per provider and host. * In TREK Studio the chat is about a journey and its book, so the banner * speaks of those; a picture of a page has the Studio's own notice. */ export default function AssistantPrivacyBanner() { const { t } = useTranslation(); const toast = useToast(); const effective = useAssistantStore((s) => s.status?.effective ?? null); const acked = useAssistantStore((s) => s.status?.privacyAcked ?? true); const ackPrivacy = useAssistantStore((s) => s.ackPrivacy); const [details, setDetails] = useState(false); // The Studio's chat reads a journey, never a trip, and may show pages once the user allows it. const book = useAssistantScope().kind === 'journey'; if (!effective || effective.source !== 'instance' || acked) return null; const provider = providerLabel(effective.kind, effective.host); const confirm = async () => { try { await ackPrivacy(); } catch { toast.error(t('assistant.error.generic')); } }; return (
{book ? t('assistant.privacy.bannerBook', { provider }) : t('assistant.privacy.banner', { provider })}