summaryrefslogtreecommitdiff
path: root/lib/items-tech/table/top/import-item-handler.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-07-17 10:50:52 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-07-17 10:50:52 +0000
commit2ef02e27dbe639876fa3b90c30307dda183545ec (patch)
treee132ae7f3dd774e1ce767291c2849be4a63ae762 /lib/items-tech/table/top/import-item-handler.tsx
parentfb276ed3db86fe4fc0c0fcd870fd3d085b034be0 (diff)
(최겸) 기술영업 변경사항 적용
Diffstat (limited to 'lib/items-tech/table/top/import-item-handler.tsx')
-rw-r--r--lib/items-tech/table/top/import-item-handler.tsx28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/items-tech/table/top/import-item-handler.tsx b/lib/items-tech/table/top/import-item-handler.tsx
index 541ec4ef..0a163791 100644
--- a/lib/items-tech/table/top/import-item-handler.tsx
+++ b/lib/items-tech/table/top/import-item-handler.tsx
@@ -8,7 +8,7 @@ const TOP_WORK_TYPES = ["TM", "TS", "TE", "TP"] as const;
// 아이템 데이터 검증을 위한 Zod 스키마
const itemSchema = z.object({
- itemCode: z.string().min(1, "아이템 코드는 필수입니다"),
+ itemCode: z.string().optional(),
workType: z.enum(TOP_WORK_TYPES, {
required_error: "기능(공종)은 필수입니다",
}),
@@ -19,7 +19,7 @@ const itemSchema = z.object({
interface ProcessResult {
successCount: number;
errorCount: number;
- errors?: Array<{ row: number; message: string }>;
+ errors: Array<{ row: number; message: string; itemCode?: string; workType?: string }>;
}
/**
@@ -45,7 +45,7 @@ export async function processTopFileImport(
// 데이터 행이 없으면 빈 결과 반환
if (dataRows.length === 0) {
- return { successCount: 0, errorCount: 0 };
+ return { successCount: 0, errorCount: 0, errors: [] };
}
// 각 행에 대해 처리
@@ -81,7 +81,12 @@ export async function processTopFileImport(
err => `${err.path.join('.')}: ${err.message}`
).join(', ');
- errors.push({ row: rowIndex, message: errorMessage });
+ errors.push({
+ row: rowIndex,
+ message: errorMessage,
+ itemCode: cleanedRow.itemCode,
+ workType: cleanedRow.workType
+ });
errorCount++;
continue;
}
@@ -99,15 +104,24 @@ export async function processTopFileImport(
} else {
errors.push({
row: rowIndex,
- message: result.message || result.error || "알 수 없는 오류"
+ message: result.message || result.error || "알 수 없는 오류",
+ itemCode: cleanedRow.itemCode,
+ workType: cleanedRow.workType
});
errorCount++;
}
} catch (error) {
console.error(`${rowIndex}행 처리 오류:`, error);
+
+ // cleanedRow가 정의되지 않은 경우를 처리
+ const itemCode = row["자재 그룹"] || row["itemCode"] || "";
+ const workType = row["기능(공종)"] || row["workType"] || "";
+
errors.push({
row: rowIndex,
- message: error instanceof Error ? error.message : "알 수 없는 오류"
+ message: error instanceof Error ? error.message : "알 수 없는 오류",
+ itemCode: typeof itemCode === 'string' ? itemCode.trim() : String(itemCode).trim(),
+ workType: typeof workType === 'string' ? workType.trim() : String(workType).trim()
});
errorCount++;
}
@@ -122,6 +136,6 @@ export async function processTopFileImport(
return {
successCount,
errorCount,
- errors: errors.length > 0 ? errors : undefined
+ errors
};
}