import Link from "next/link"; import { getLocale, getTranslations } from "next-intl/server"; import { Hourglass, Lock } from "lucide-react"; import { cn } from "@/lib/utils"; import { formatDateKey, formatInstantDate } from "@/lib/trial/dates"; import { trialContactEmail } from "@/server/services/trial/config"; import { getTrialState } from "@/server/services/trial/state"; /** * L15 Testphase: banner in the backoffice and mobile shell — countdown from 7 days before the end, * read-only notice (+ deletion date, contact, export link) after expiry. Status is carried by text * and icon, colour only supports it. */ export async function TrialBanner({ tenantId, variant, canExport = false }: { tenantId: string; variant: "backoffice" | "mobile"; canExport?: boolean }) { const state = await getTrialState(tenantId); if (!state.isTrial || (!state.expired && !state.showCountdown)) return null; const [t, locale] = await Promise.all([getTranslations("trial.banner"), getLocale()]); const contact = trialContactEmail(); const Icon = state.expired ? Lock : Hourglass; return (
{state.expired ? t("expired") : t("endsIn", { days: Math.max(0, state.daysLeft ?? 0) })} {!state.expired && state.endDateKey && {t("endsOn", { date: formatDateKey(state.endDateKey, locale) })}} {state.expired && state.deletionDueAt && {t("deletion", { date: formatInstantDate(state.deletionDueAt, locale) })}} {contact ? ( <> {t("contact", { email: "" })} {contact} ) : ( t("contactGeneric") )} {state.expired && canExport && ( {t("export")} )}
); }