import { useState } from "react"; import { copy, type Language } from "../copy"; import { DemoPreview } from "./DemoPreview"; import { OnboardingFrame } from "./OnboardingFrame"; export type ConsentPayload = { ai_disclosure: boolean; interpreter_right: boolean; recorded_at: string; scope: "translation_aid"; }; type ConsentGateProps = { error: string | null; isSubmitting: boolean; language?: Language; onConsent: (payload: ConsentPayload) => void; }; export function ConsentGate({ error, isSubmitting, language = "vi", onConsent }: ConsentGateProps) { const [aiDisclosure, setAiDisclosure] = useState(false); const [interpreterRight, setInterpreterRight] = useState(false); const [consentSubmitted, setConsentSubmitted] = useState(false); const bothChecked = aiDisclosure && interpreterRight; const canStart = bothChecked && !isSubmitting; const text = copy[language].consent; const otherLang = language === "vi" ? "en" : "vi"; const companion = copy[otherLang].consent; return (

{text.description}

{companion.description}

{text.limitation}
{companion.limitation}

{ event.preventDefault(); if (!canStart) { return; } setConsentSubmitted(true); onConsent({ ai_disclosure: true, interpreter_right: true, recorded_at: new Date().toISOString(), scope: "translation_aid", }); }} >
{text.acknowledgements}
{error ?

{error}

: null}

{bothChecked ? text.startReadyHint : text.startHint} {bothChecked ? companion.startReadyHint : companion.startHint}

); }