import { currentLanguageIndex, ui_locales } from "@ui/ui_template_locale"; import { hideLoadingOverlay, showLoadingOverlay, showToast } from "@ui/ui_template_elements"; import type { DashboardUser } from "./B01_Dashboard_Api_Fetch"; export function L(key: keyof typeof ui_locales): string { return ui_locales[key][currentLanguageIndex]; } export function roleLabel(role: DashboardUser["role"]): string { if (role === "SYSTEM_ADMIN") return L("B01_Dashboard_Role_SystemAdmin"); if (role === "ADMIN") return L("B01_Dashboard_Role_Admin"); return L("B01_Dashboard_Role_User"); } export async function runRequest(action: () => Promise): Promise { showLoadingOverlay(); try { await action(); showToast(L("B01_Dashboard_Saved"), "success"); } catch (error) { showToast(error instanceof Error ? error.message : L("B01_Dashboard_RequestFailed"), "error"); } finally { hideLoadingOverlay(); } } export function formatDate(value?: string | null): string { return value ? value.slice(0, 10) : "-"; }