feat(M01): 테스트 컨테이너에 방식 B·C 잇기 + 재료 고르기 후보 API 연결

- 탭 A·B·C 모두 연결
- 방식 A 재료 고르기 단계 = GET /materials 조건 후보(조건형 요소일 때)
- 화면 계약에 /materials 한 줄

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT
This commit is contained in:
2026-09-20 21:54:12 +09:00
co-authored by Claude Sonnet 5
parent 826495f199
commit be4bed801c
4 changed files with 27 additions and 3 deletions
@@ -165,6 +165,14 @@ export const searchElements = (
): Promise<{ total: number; items: ElementBrief[] }> =>
request(`/elements?${query({ group, q, limit: "100" })}`);
export const fetchMaterials = (cond: {
sub: string;
detail?: string;
spec?: string;
region?: string;
}): Promise<{ total: number; 기본: string | null; items: ElementBrief[] }> =>
request(`/materials?${query({ ...cond, limit: "100" })}`);
export const runCalc = (body: {
key: string;
inputs: Record<string, unknown>;
+4 -2
View File
@@ -8,6 +8,8 @@
import { createSelectField, el, showToast } from "@ui/ui_template_elements";
import { fetchLogics } from "./M01_MasterData_UI_Logic_Api";
import { render as renderA } from "./M01_MasterData_UI_Test_A";
import { render as renderB } from "./M01_MasterData_UI_Test_B";
import { render as renderC } from "./M01_MasterData_UI_Test_C";
import { tt } from "./M01_MasterData_UI_Test_Text";
import "./M01_MasterData_UI_Test_Style.css";
@@ -31,8 +33,8 @@ type Render = (host: HTMLElement, logicKey: string) => void;
/** 방식 파일이 오면 여기 한 줄씩 잇는다 — null 은 준비 중 */
const METHODS: { id: string; label: () => string; render: Render | null }[] = [
{ id: "A", label: () => tt("Tab_A"), render: renderA },
{ id: "B", label: () => tt("Tab_B"), render: null },
{ id: "C", label: () => tt("Tab_C"), render: null },
{ id: "B", label: () => tt("Tab_B"), render: renderB },
{ id: "C", label: () => tt("Tab_C"), render: renderC },
];
export function mountM01Test(host: HTMLElement): void {
+13 -1
View File
@@ -7,6 +7,7 @@
import { createButton, createSelectField, el, showToast } from "@ui/ui_template_elements";
import {
fetchLogic,
fetchMaterials,
runCalc,
searchElements,
type CalcAnswer,
@@ -147,7 +148,18 @@ function wizard(host: HTMLElement, one: LogicOne): void {
else swaps.delete(i);
},
});
void searchElements(line., line. ?? "")
// 재료 고르기 조건({구분, 상세구분, 규격}) 이면 새 API 로 조건 안 후보 · 아니면 이름 찾기
const cond = line. as unknown;
const found_ =
cond && typeof cond === "object"
? fetchMaterials({
sub: String((cond as Record<string, unknown>)["구분"] ?? ""),
detail: String((cond as Record<string, unknown>)["상세구분"] ?? ""),
spec: String((cond as Record<string, unknown>)["규격"] ?? ""),
region: "울진",
})
: searchElements(line., line. ?? "");
void found_
.then((r) => {
r.items.forEach((it) => found.set(it.ref, it));
select.setOptions(