"use client"; /** * v1.23 — "Data & Privacy" dashboard (P7). * * One coherent pane that ASSEMBLES already-shipped machinery — it does not * rebuild any of it. Each block either embeds an existing card (active * sessions, security activity, trusted devices) or links to the existing * surface that owns the action (export incl. the passphrase option, account * deletion / data reset, AI privacy mode, research mode). The retention + * encryption facts are read from the server so the copy stays truthful, and * the backup↔deletion lag is disclosed honestly. */ import { useQuery } from "@tanstack/react-query"; import Link from "next/link"; import { Database, Download, ShieldCheck, Trash2, Clock, Sparkles, Info, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { SettingsCardActions } from "@/components/settings/_card-actions"; import { Skeleton } from "@/components/ui/skeleton"; import { SettingsCard } from "@/components/settings/settings-card"; import { SettingsCardHeader } from "@/components/settings/_card-header"; import { SettingsInfoTile } from "@/components/settings/_info-tile"; import { SecuritySessionsCard } from "@/components/settings/security-sessions-card"; import { SecurityActivityCard } from "@/components/settings/security-activity-card"; import { TrustedDevicesCard } from "@/components/settings/trusted-devices-card"; import { useAuth } from "@/hooks/use-auth"; import { useTranslations } from "@/lib/i18n/context"; import { MODULE_KEYS, MODULE_REGISTRY } from "@/lib/modules/registry"; import { queryKeys } from "@/lib/query-keys"; import { apiGet } from "@/lib/api/api-fetch"; import { QueryErrorRow } from "@/components/ui/query-error-row"; interface PrivacySummary { retention: { coachMessagesDays: number; auditLogDays: number; deliveryLogDays: number; }; encryption: { algorithm: string; columnCount: number; modelCount: number; }; } /** * The modules that keep records of their own, read off the module registry * so a new module joins the "What's stored" list without anyone editing it. * The hand-kept list this replaced had stopped at six lines while documents, * vaccinations, the cycle and workouts were all being stored. Two categories * hold nothing of their own: an export assembles what other modules store, * and the connector's tokens are covered by the integration line. */ export function storedModuleLabelKeys(): string[] { return MODULE_KEYS.map((key) => MODULE_REGISTRY[key]) .filter((m) => m.category !== "export" && m.category !== "integration") .map((m) => m.labelKey); } export function PrivacySection() { const { t, locale } = useTranslations(); const { isAuthenticated } = useAuth(); const { data: summary, isLoading: summaryLoading, isError: summaryError, error: summaryFailure, refetch: refetchSummary, } = useQuery({ queryKey: queryKeys.privacySummary(), queryFn: () => apiGet("/api/settings/privacy-summary"), enabled: isAuthenticated, }); return (
{/* Encryption at rest */}

{summary ? t("settings.privacy.encryption.summary", { algorithm: summary.encryption.algorithm, columns: summary.encryption.columnCount, models: summary.encryption.modelCount, }) : t("settings.privacy.encryption.statement")}

{/* What's stored */}
  • {t("settings.privacy.stored.measurements")}
  • {t("settings.privacy.stored.profile")}
  • {t("settings.privacy.stored.modules", { list: new Intl.ListFormat(locale, { style: "long", type: "conjunction", }).format(storedModuleLabelKeys().map((key) => t(key))), })}
  • {t("settings.privacy.stored.integrations")}
  • {t("settings.privacy.stored.security")}
{/* Retention */} {summaryLoading ? (
) : summaryError && !summary ? ( void refetchSummary()} /> ) : !summary ? (

{t("settings.privacy.retention.unavailable")}

) : (
  • {t("settings.privacy.retention.coach", { days: summary.retention.coachMessagesDays, })}
  • {t("settings.privacy.retention.audit", { days: summary.retention.auditLogDays, })}
  • {t("settings.privacy.retention.delivery", { days: summary.retention.deliveryLogDays, })}
)}
{/* Export */} {/* Delete / reset — with the honest backup lag disclosure */} {t("settings.privacy.delete.backupLag")} {/* Privacy posture. The AI privacy mode is what is left to decide here: research mode is gone, so the second button pointed at a page that no longer carries the control it named. */} {/* Active sessions + trusted devices + security activity (embedded) */}
); }