/* ============================================================================= * M02_DF_Api.ts * 단위 · 금액 표준 표 읽기 — 서버 `GET /api/m02/df/standards`(`M02_DF_Router.py`) * 부르는 곳 = 단위 고르기(`M02_DF_UnitPick`) · 끝수 표준(`M02_DF_Round`) · 옵션 기계 이름(`formula_doc_options`) * ========================================================================== */ import { API_BASE_URL } from "@config/config_frontend"; /** 단위 · 금액 표준 표 */ export interface CfStandards { unit: { 이름: string; 줄: Record[]; [k: string]: unknown }; money: { 이름: string; 줄: Record[]; [k: string]: unknown }; saved: boolean; } export async function cfStandards(): Promise { const response = await fetch(`${API_BASE_URL}/m02/df/standards`, { credentials: "include" }); if (!response.ok) throw new Error(`표준 표 읽기 실패 (${response.status})`); return (await response.json()) as CfStandards; } let machineNames: Promise> | null = null; /** 기계 원문번호 → 「이름 규격」 — 한 번 받아 둠(못 받으면 빈 표 · 다음에 다시) */ export function cfMachineNames(): Promise> { machineNames ??= fetch(`${API_BASE_URL}/m02/df/machine-names`, { credentials: "include" }) .then((r) => (r.ok ? (r.json() as Promise>) : Promise.reject())) .catch(() => ((machineNames = null), {})); return machineNames; }