diff --git a/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx b/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx index 1eca9fab..7bf7a81d 100644 --- a/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx +++ b/frontend/lib/registry/components/modal-repeater-table/ItemSelectionModal.tsx @@ -17,6 +17,7 @@ import { Search, Loader2 } from "lucide-react"; import { useEntitySearch } from "../entity-search-input/useEntitySearch"; import { ItemSelectionModalProps, ModalFilterConfig } from "./types"; import { apiClient } from "@/lib/api/client"; +import { getCategoryLabelsByCodes } from "@/lib/api/tableCategoryValue"; export function ItemSelectionModal({ open, @@ -99,13 +100,44 @@ export function ItemSelectionModal({ } } - // 정렬 후 옵션으로 변환 + // 🆕 CATEGORY_ 코드가 있는지 확인하고 라벨 조회 + const allCodes = new Set(); + for (const val of uniqueValues) { + // 콤마로 구분된 다중 값도 처리 + const codes = val.split(",").map(c => c.trim()); + codes.forEach(code => { + if (code.startsWith("CATEGORY_")) { + allCodes.add(code); + } + }); + } + + // CATEGORY_ 코드가 있으면 라벨 조회 + let labelMap: Record = {}; + if (allCodes.size > 0) { + try { + const labelResponse = await getCategoryLabelsByCodes(Array.from(allCodes)); + if (labelResponse.success && labelResponse.data) { + labelMap = labelResponse.data; + } + } catch (labelError) { + console.error("카테고리 라벨 조회 실패:", labelError); + } + } + + // 정렬 후 옵션으로 변환 (라벨 적용) const options = Array.from(uniqueValues) .sort() - .map((val) => ({ - value: val, - label: val, - })); + .map((val) => { + // 콤마로 구분된 다중 값 처리 + if (val.includes(",")) { + const codes = val.split(",").map(c => c.trim()); + const labels = codes.map(code => labelMap[code] || code); + return { value: val, label: labels.join(", ") }; + } + // 단일 값 + return { value: val, label: labelMap[val] || val }; + }); setCategoryOptions((prev) => ({ ...prev,