"use client"; import React, { useState } from "react"; import { useConsent, type ConsentState } from "./ConsentProvider"; import { useTranslations } from "next-intl"; export default function ConsentBanner() { const { consent, ready, setConsent } = useConsent(); const [draft, setDraft] = useState({ analytics: false, chat: false }); const [minimized, setMinimized] = useState(false); const t = useTranslations("consent"); // Avoid hydration mismatch + avoid "flash then disappear": // Only decide whether to show the banner after consent has been read client-side. const shouldShow = ready && consent === null; if (!shouldShow) return null; const s = { title: t("title"), description: t("description"), essential: t("essential"), analytics: t("analytics"), chat: t("chat"), alwaysOn: t("alwaysOn"), acceptAll: t("acceptAll"), acceptSelected: t("acceptSelected"), rejectAll: t("rejectAll"), hide: t("hide"), }; if (minimized) { return (
); } return (
{s.title}

{s.description}

{s.essential}
{s.alwaysOn}
); }