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"; /** * 목록형 컨테이너가 한 번에 보여 주는 행 수. 넘치는 만큼은 컨테이너 안에서 스크롤한다 — * 자료가 쌓여도 대시보드 세로 길이가 늘어나지 않게(2026-08-08 사용자 지시). */ export const DASHBOARD_VISIBLE_ROWS = 4; 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) : "-"; }