fix(modal-repeater-table): 날짜 필드 ISO 형식 변환으로 표시 오류 수정

- RepeaterTable에서 DB 조회된 ISO 형식 날짜를 yyyy-mm-dd로 변환
- formatDateValue 함수 추가: ISO 문자열, Date 객체, 기존 형식 모두 처리
- 수주일(order_date), 납기일(item_due_date) 등 날짜 필드 정상 표시
This commit is contained in:
SeongHyun Kim 2025-12-05 10:13:59 +09:00
parent 5c12b9fa83
commit 5d3b3ea76e
1 changed files with 19 additions and 1 deletions

View File

@ -75,10 +75,28 @@ export function RepeaterTable({
);
case "date":
// ISO 형식(2025-11-23T00:00:00.000Z)을 yyyy-mm-dd로 변환
const formatDateValue = (val: any): string => {
if (!val) return "";
// 이미 yyyy-mm-dd 형식이면 그대로 반환
if (typeof val === "string" && /^\d{4}-\d{2}-\d{2}$/.test(val)) {
return val;
}
// ISO 형식이면 날짜 부분만 추출
if (typeof val === "string" && val.includes("T")) {
return val.split("T")[0];
}
// Date 객체이면 변환
if (val instanceof Date) {
return val.toISOString().split("T")[0];
}
return String(val);
};
return (
<Input
type="date"
value={value || ""}
value={formatDateValue(value)}
onChange={(e) => handleCellEdit(rowIndex, column.field, e.target.value)}
className="h-7 text-xs"
/>