Files
Aislo/M02_MasterTemplete/M02_MyMaterial_Api.ts
T
eomsangdonandClaude Opus 5.5 207be5bd71 feat(840-4): 내 재료 = 재료 DB(M01)에 없는 자재를 등록하는 자리 — 개인관리 › 자재 등록 칸(만들기 · 고치기 · 지우기) · M01 과 같은 이름 · 규격 · 단위 막음 · 단가산출 재료 고르기 「내 재료」 · 값 바꾸면 자동 따라옴
- 서버 `M02_Material_Own`: M01 자재품목과 이름 · 규격 · 단위 같음 = 409(빈칸 · 대소문자 · ㎏ = kg 무시) · 고치기 · 지우기(쓰는 곳 있으면 409 · 밑줄 폴더 보관본 뺌) · 목록 줄마다 쓰는 곳
- 셈 색인: 단가산출 사본 색인 · 사본 모으기 · 빈틈 채우기에 내 재료 줄을 내 기계처럼 얹음 → 개인 층 단가산출은 값 바뀌면 836-2 길로 따라옴 · 프로젝트 층 = 사본 값
- 화면: 개인관리 › 자재 위 「내 재료」 표 + 고침 칸(`M02_MyMaterial_View` · `M02_MyMaterial_Api`) · 아래 「값을 바로 적은 재료」 모아 보기는 읽기 그대로 · 찾아 넣기 재료 탭 M01 위 「내 재료」 묶음(줄 쌓기 개인 층)
- M01 재료를 본떠 값만 바꾼 내 재료를 만드는 길 = 없었음(걷을 것 없음)

낡은 시험 고침: test_m02_material_own 목록 줄에 「쓰는곳」 칸

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:40:08 +09:00

46 lines
1.7 KiB
TypeScript

/* =============================================================================
* M02_MyMaterial_Api.ts
* M02 내 재료(개인 자재 PM · PLAN 840-4) 서버 호출 — 개인 층만 · 서버 `M02_Labor_Router` 의 /layers/personal/materials
* 목록(줄마다 쓰는 곳) · 만들기 · 고치기 · 지우기(쓰는 곳 있으면 409) · M01 재료 DB 와 같은 이름 · 규격 · 단위 = 409
* ========================================================================== */
import { call } from "./M02_MasterTemplete_Api_Fetch";
export interface MyMaterialUse {
종류: string;
키: string;
이름: string;
}
export interface MyMaterial {
키: string;
이름: string;
규격: string;
단위: string;
값: number | null;
쓰는곳?: MyMaterialUse[];
}
export type MyMaterialBody = Pick<MyMaterial, "이름" | "규격" | "단위" | "값">;
const path = (owner: string | null, key = ""): string =>
`/layers/personal/materials${key ? `/${encodeURIComponent(key)}` : ""}${
owner ? `?owner=${encodeURIComponent(owner)}` : ""
}`;
export const listMyMaterials = (owner: string | null): Promise<MyMaterial[]> =>
call<{ 줄: MyMaterial[] }>(path(owner)).then((d) => d.줄);
export const addMyMaterial = (owner: string | null, body: MyMaterialBody): Promise<MyMaterial> =>
call<MyMaterial>(path(owner), { method: "POST", body: JSON.stringify(body) });
export const editMyMaterial = (
owner: string | null,
key: string,
body: MyMaterialBody,
): Promise<MyMaterial> =>
call<MyMaterial>(path(owner, key), { method: "PUT", body: JSON.stringify(body) });
export const dropMyMaterial = (owner: string | null, key: string): Promise<unknown> =>
call(path(owner, key), { method: "DELETE" });