Phase 18: Auto timezone detection and ability to change timezone #21

Merged
luckberg merged 38 commits from gsd/phase-18-auto-timezone-detection-and-ability-to-change-timezone into main 2026-06-15 09:55:53 -04:00
Showing only changes of commit 57424e6770 - Show all commits
+42
View File
@@ -468,6 +468,48 @@ export async function setSharedCalendar(calendarId: number): Promise<void> {
handleAuthResponse(res, `PUT /api/admin/calendars/${calendarId}/shared`); handleAuthResponse(res, `PUT /api/admin/calendars/${calendarId}/shared`);
} }
/**
* Response shape for GET /api/admin/config/timezone.
* isExplicitlySet is false when the household timezone has not been saved yet
* (the server returns the process.env.TZ / Intl fallback in that case — D-06).
*/
export interface AdminTimezoneResponse {
timezone: string;
isExplicitlySet: boolean;
}
/**
* Fetch the current household timezone setting.
* Admin-only: the server enforces requireAdmin (403 for non-admins).
*/
export async function fetchAdminTimezone(): Promise<AdminTimezoneResponse> {
const res = await fetch('/api/admin/config/timezone', {
credentials: 'include',
redirect: 'manual',
});
handleAuthResponse(res, 'GET /api/admin/config/timezone');
return res.json() as Promise<AdminTimezoneResponse>;
}
/**
* Set the household timezone.
* Admin-only: the server enforces requireAdmin and IANA validation (Plan 02).
* @param timezone A valid IANA timezone identifier (e.g. 'America/Chicago').
*/
export async function setAdminTimezone(timezone: string): Promise<void> {
const res = await fetch('/api/admin/config/timezone', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
redirect: 'manual',
body: JSON.stringify({ timezone }),
});
handleAuthResponse(res, 'PUT /api/admin/config/timezone');
}
/** /**
* Self-service: save (add) the current member's own credential. * Self-service: save (add) the current member's own credential.
* Member-scoped: NO userId in payload — server resolves from session (Pitfall 6 / T-10-12). * Member-scoped: NO userId in payload — server resolves from session (Pitfall 6 / T-10-12).