Files
temetro/frontend/components/settings/settings-view.tsx
T
Khalid Abdi 4d6a5dc008 Migrate UI to COSS components + COSS neutral theme; add i18next
Components:
- Replace components/ui primitives with COSS equivalents from the @coss/* shadcn
  registry. Add menu/preview-card/group; remove the superseded dropdown-menu,
  hover-card, button-group; keep carousel (no COSS equivalent).
- Migrate live call sites to canonical COSS APIs preserving layout/behavior:
  sidebar menus (nav-user, team-switcher, nav-notifications), chat-input radio
  menu, patient dialogs/cards, auth forms (FieldGroup -> flex column), settings.
- ai-elements: migrate the live conversation/message with behavior parity
  (Tooltip via render, Group/GroupText); repoint dormant files (hover-card ->
  preview-card, dropdown-menu -> menu, button-group -> group, InputGroupButton
  -> Button). Residual pre-existing Base UI type drift stays behind
  ignoreBuildErrors.

Theme:
- Adopt COSS default neutral tokens in globals.css with light + dark palettes.
- Add next-themes (defaultTheme=dark, enableSystem) and drop the forced dark
  class. Align font variables to the COSS contract (--font-sans/-heading/-mono).
  Make scrollbars theme-aware.

i18n:
- Add i18next + react-i18next (lib/i18n/config.ts, locales/en/translation.json,
  components/i18n-provider.tsx mounted in layout). Convert auth forms, sidebar
  nav, and settings tabs to useTranslation() as the reference pattern.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 18:39:20 +03:00

91 lines
2.7 KiB
TypeScript

"use client";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils";
import {
SettingsCard,
SettingsSection,
} from "@/components/settings/settings-parts";
import { SigningPanel } from "@/components/settings/settings-billing";
import { CareTeamPanel } from "@/components/settings/settings-care-team";
import { ProfilePanel } from "@/components/settings/settings-preferences";
const TABS = [
{ id: "profile", labelKey: "settings.tabs.profile" },
{ id: "records", labelKey: "settings.tabs.records" },
{ id: "signing", labelKey: "settings.tabs.signing" },
{ id: "careTeam", labelKey: "settings.tabs.careTeam" },
{ id: "developers", labelKey: "settings.tabs.developers" },
] as const;
type Tab = (typeof TABS)[number]["id"];
function PlaceholderPanel({
title,
description,
}: {
title: string;
description: string;
}) {
const { t } = useTranslation();
return (
<SettingsSection description={description} title={title}>
<SettingsCard className="flex items-center justify-center p-12">
<p className="text-sm text-muted-foreground">{t("settings.empty")}</p>
</SettingsCard>
</SettingsSection>
);
}
export function SettingsView() {
const { t } = useTranslation();
const [tab, setTab] = useState<Tab>("profile");
return (
<div className="mx-auto w-full max-w-3xl px-6 py-10">
<div className="flex flex-col gap-5 sm:flex-row sm:items-center sm:justify-between">
<h1 className="text-2xl font-semibold tracking-tight">
{t(`settings.tabs.${tab}`)}
</h1>
<nav className="flex flex-wrap items-center gap-1">
{TABS.map((item) => (
<button
className={cn(
"rounded-lg px-3 py-1.5 text-sm transition-colors",
tab === item.id
? "bg-muted text-foreground"
: "text-muted-foreground hover:text-foreground"
)}
key={item.id}
onClick={() => setTab(item.id)}
type="button"
>
{t(item.labelKey)}
</button>
))}
</nav>
</div>
<div className="mt-10 space-y-12">
{tab === "profile" && <ProfilePanel />}
{tab === "records" && (
<PlaceholderPanel
description={t("settings.records.description")}
title={t("settings.tabs.records")}
/>
)}
{tab === "signing" && <SigningPanel />}
{tab === "careTeam" && <CareTeamPanel />}
{tab === "developers" && (
<PlaceholderPanel
description={t("settings.developers.description")}
title={t("settings.tabs.developers")}
/>
)}
</div>
</div>
);
}