"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, Lock, ShieldCheck, Trash2, Clock, Sparkles, Info, } from "lucide-react"; import { Button } from "@/components/ui/button"; 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 { queryKeys } from "@/lib/query-keys"; import { apiGet } from "@/lib/api/api-fetch"; interface PrivacySummary { retention: { coachMessagesDays: number; auditLogDays: number; deliveryLogDays: number; }; encryption: { algorithm: string; columnCount: number; modelCount: number; }; } export function PrivacySection() { const { t } = useTranslations(); const { isAuthenticated } = useAuth(); const { data: summary, isLoading: summaryLoading, isError: summaryError, } = useQuery({ queryKey: queryKeys.privacySummary(), queryFn: () => apiGet("/api/settings/privacy-summary"), enabled: isAuthenticated, }); return (
{/* Intro */} {t("settings.privacy.intro.body")} {/* 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.medications")}
  • {t("settings.privacy.stored.moodLabs")}
  • {t("settings.privacy.stored.coach")}
  • {t("settings.privacy.stored.integrations")}
  • {t("settings.privacy.stored.security")}
{/* Retention */} {summaryLoading ? (
) : summaryError || !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 (AI privacy mode + research mode live on their pages) */}
{/* Active sessions + trusted devices + security activity (embedded) */}
); }