"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 states a fact or links to the surface that * owns the action (account deletion / data reset, AI privacy mode). The * retention + encryption facts are read from the server so the copy stays * truthful, and the backup↔deletion lag is disclosed honestly. * * v1.44 — the active sessions, trusted devices and security activity moved * to Settings > Security beside the sign-in controls, and the export card * left: Export & import and the Health record sit next to this page in the * Data group. The old anchors forward (`settings-anchor-forward.tsx`). */ import { useQuery } from "@tanstack/react-query"; import Link from "next/link"; import { Database, ShieldCheck, Trash2, Clock, Sparkles, Info, MonitorSmartphone, } 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 { WorkoutRoutesCard } from "@/components/settings/workout-routes-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")}
{/* Workout GPS tracks: kept only on opt-in. */} {/* 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, })}
)}
{/* Sessions, trusted devices and the security activity live under Security since v1.44; the row keeps them reachable from here, where people looked for them before. */} {/* 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. */}
); }