Files
temetro/frontend/lib/settings.ts
T
Khalid Abdi 470230591c frontend: working profile settings with sticky save + real account deletion
- ToggleRow supports controlled checked/onCheckedChange; CopyField copy works
- ProfilePanel loads/saves preferences via /api/settings, name via updateUser
- dirty tracking with a sticky save bar that follows the scroll
- Delete account: password-confirmed dialog wired to authClient.deleteUser
- clinician ID / handle now show the real session user

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

25 lines
803 B
TypeScript

import { apiFetch } from "@/lib/api-client";
// Per-user preferences persisted by the backend (`user_settings` table) as a
// flat key → boolean/string map. Unknown keys are preserved, so features can
// add settings without coordinating with this file.
export type UserPreferences = Record<string, boolean | string>;
export async function getSettings(): Promise<UserPreferences> {
const res = await apiFetch<{ preferences: UserPreferences }>("/api/settings");
return res.preferences ?? {};
}
export async function saveSettings(
preferences: UserPreferences,
): Promise<UserPreferences> {
const res = await apiFetch<{ preferences: UserPreferences }>(
"/api/settings",
{
method: "PUT",
body: JSON.stringify({ preferences }),
},
);
return res.preferences ?? {};
}