From 46c628c34d72c5d6a4f08ffbde95606b3bb10671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=98=81=EB=B3=B4?= Date: Mon, 23 Mar 2026 10:56:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[=ED=92=88=EB=AA=A9]=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=A1=9C=EB=93=9C=20=EC=8B=9C=20item=5Fcode?= =?UTF-8?q?=E2=86=92code=20=EC=97=AD=EB=A7=A4=ED=95=91=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 백엔드 formatItemResponse()에서 code→item_code로 키를 변환해서 응답하지만, 프론트엔드 폼 필드는 code를 기대함. mapApiResponseToFormData()에서 item_code→code 역매핑을 추가하여 수정 페이지 진입 시 기존 데이터가 정상 표시되도록 수정. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/items/ItemDetailEdit.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/items/ItemDetailEdit.tsx b/src/components/items/ItemDetailEdit.tsx index 31d94eaa..818ab55a 100644 --- a/src/components/items/ItemDetailEdit.tsx +++ b/src/components/items/ItemDetailEdit.tsx @@ -80,10 +80,17 @@ function mapApiResponseToFormData(data: ItemApiResponse): DynamicFormData { 'details', // details는 아래에서 펼쳐서 추가 ]; - // 백엔드 응답의 모든 필드를 그대로 복사 + // 백엔드 응답 필드명 → 프론트엔드 폼 필드명 역매핑 + // 백엔드 formatItemResponse()에서 code → item_code로 변환하므로 복원 필요 + const apiToFormKeyMap: Record = { + 'item_code': 'code', + }; + + // 백엔드 응답의 모든 필드를 복사 (키 변환 적용) Object.entries(data).forEach(([key, value]) => { if (!excludeKeys.includes(key) && value !== null && value !== undefined) { - formData[key] = value as DynamicFormData[string]; + const formKey = apiToFormKeyMap[key] || key; + formData[formKey] = value as DynamicFormData[string]; } });