mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
470230591c
- 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>
25 lines
803 B
TypeScript
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 ?? {};
|
|
}
|