- 11.1 MainLayout health indicator: warning MessageBar when fail2ban offline - 11.2 formatDate utility + TimezoneProvider + GET /api/setup/timezone - 11.3 Responsive sidebar: auto-collapse <640px, media query listener - 11.4 PageFeedback (PageLoading/PageError/PageEmpty), BanTable updated - 11.5 prefers-reduced-motion: disable sidebar transition - 11.6 WorldMap ARIA: role/tabIndex/aria-label/onKeyDown for countries - 11.7 Health transition logging (fail2ban_came_online/went_offline) - 11.8 Global handlers: Fail2BanConnectionError/ProtocolError -> 502 - 11.9 379 tests pass, 82% coverage, ruff+mypy+tsc+eslint clean - Timezone endpoint: setup_service.get_timezone, 5 new tests
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
/**
|
|
* Setup wizard API functions.
|
|
*
|
|
* Wraps calls to GET /api/setup and POST /api/setup.
|
|
*/
|
|
|
|
import { api } from "./client";
|
|
import { ENDPOINTS } from "./endpoints";
|
|
import type {
|
|
SetupRequest,
|
|
SetupResponse,
|
|
SetupStatusResponse,
|
|
SetupTimezoneResponse,
|
|
} from "../types/setup";
|
|
|
|
/**
|
|
* Check whether the initial setup has been completed.
|
|
*
|
|
* @returns Setup status response with a `completed` boolean.
|
|
*/
|
|
export async function getSetupStatus(): Promise<SetupStatusResponse> {
|
|
return api.get<SetupStatusResponse>(ENDPOINTS.setup);
|
|
}
|
|
|
|
/**
|
|
* Submit the initial setup configuration.
|
|
*
|
|
* @param data - Setup request payload.
|
|
* @returns Success message from the API.
|
|
*/
|
|
export async function submitSetup(data: SetupRequest): Promise<SetupResponse> {
|
|
return api.post<SetupResponse>(ENDPOINTS.setup, data);
|
|
}
|
|
|
|
/**
|
|
* Fetch the IANA timezone configured during setup.
|
|
*
|
|
* Used by the frontend to convert UTC timestamps to the local timezone
|
|
* chosen by the administrator.
|
|
*
|
|
* @returns The configured timezone identifier (e.g. `"Europe/Berlin"`).
|
|
*/
|
|
export async function fetchTimezone(): Promise<SetupTimezoneResponse> {
|
|
return api.get<SetupTimezoneResponse>(ENDPOINTS.setupTimezone);
|
|
}
|