/* ============================================================================= * M02_MyMachine_Impact.ts * 내 기계 저장 전 영향 확인창(PLAN 848-5 · 요구서 889 6 장) — 기계 보기 [저장] 이 고침 저장 전에 부름. * 바뀐 칸이 없거나 쓰는 단가산출이 없으면 묻지 않음 · 서버가 셈(`…/my-machines/{키}/impact` — 쓰기 없음): * 이 층 쓰는 단가산출 목록(그 칸을 따로 고쳐 두어 안 바뀌는 것 표시) → [저장] / [취소]. * 부품 = 확인창(`askConfirm` detail) · 표 · 글. * ========================================================================== */ import { createDataTable } from "@ui/ui_template_data_table"; import { askConfirm } from "@ui/ui_template_modal"; import { createText } from "@ui/ui_template_text"; import { el } from "@ui/ui_template_elements"; import { impactMyMachine, type MyMachineBody } from "./M02_MyMachine_Api"; /** 저장해도 되면 true */ export async function confirmMyMachineImpact( owner: string | null, key: string, body: MyMachineBody, ): Promise { const got = await impactMyMachine(owner, key, body); if (!got.칸.length || !got.쓰는곳.length) return true; const kept = got.고침 + got.위층; const table = createDataTable({ caption: "쓰는 단가산출", columns: [ { key: "키", label: "단가산출", width: 96 }, { key: "이름", label: "이름", width: 240 }, { key: "따로", label: "그 칸 따로 고침", width: 110 }, ], rows: got.쓰는곳.map((u) => ({ 키: u.키, 이름: u.이름, 따로: u.고침 ? "내 고침 — 안 바뀜" : u.위층 ? "위 층 고침 — 안 바뀜" : "", })), }); return askConfirm({ title: "내 기계 고침 — 영향 확인", message: `바뀐 칸: ${got.칸.join(" · ")} — 이 기계를 쓰는 단가산출 ${got.쓰는곳.length} 개에 걸림`, okLabel: "저장", cancelLabel: "취소", detail: el("div", { className: "m02-mymach__impact", children: [ createText( `그 칸을 따로 고쳐 두어 안 바뀌는 곳 ${kept} 개(내 고침 ${got.고침} · 위 층 고침 ${got.위층})`, kept ? "warning" : "muted", ), table.root, ], }), }); }