summaryrefslogtreecommitdiff
path: root/lib/vendor-pool/table/vendor-pool-table.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-pool/table/vendor-pool-table.tsx')
-rw-r--r--lib/vendor-pool/table/vendor-pool-table.tsx49
1 files changed, 46 insertions, 3 deletions
diff --git a/lib/vendor-pool/table/vendor-pool-table.tsx b/lib/vendor-pool/table/vendor-pool-table.tsx
index 46a0588d..2696b354 100644
--- a/lib/vendor-pool/table/vendor-pool-table.tsx
+++ b/lib/vendor-pool/table/vendor-pool-table.tsx
@@ -198,6 +198,7 @@ export function VendorPoolTable({ data, pageCount, onRefresh }: VendorPoolTableP
setIsSaving(true)
let successCount = 0
let errorCount = 0
+ let duplicateErrors: string[] = []
try {
// 각 항목의 변경사항을 순차적으로 저장
@@ -218,6 +219,13 @@ export function VendorPoolTable({ data, pageCount, onRefresh }: VendorPoolTableP
}
} catch (error) {
console.error(`항목 ${id} 저장 실패:`, error)
+
+ // Unique 제약 조건 위반 감지
+ const errorMessage = error instanceof Error ? error.message : String(error);
+ if (errorMessage === 'DUPLICATE_VENDOR_POOL') {
+ const changes = pendingChanges[id]
+ duplicateErrors.push(`항목 ${id}: 공사부문(${changes.constructionSector}), H/T(${changes.htDivision}), 자재그룹코드(${changes.materialGroupCode}), 협력업체명(${changes.vendorName})`)
+ }
errorCount++
}
}
@@ -233,8 +241,17 @@ export function VendorPoolTable({ data, pageCount, onRefresh }: VendorPoolTableP
onRefresh?.() // 데이터 새로고침
}
- if (errorCount > 0) {
- toast.error(`${errorCount}개 항목 저장에 실패했습니다.`)
+ // 중복 에러가 있는 경우 개별적으로 표시
+ if (duplicateErrors.length > 0) {
+ duplicateErrors.forEach(errorMsg => {
+ toast.error(`중복된 항목입니다. ${errorMsg}`)
+ })
+ }
+
+ // 일반적인 에러 메시지 (중복 에러 제외)
+ const generalErrorCount = errorCount - duplicateErrors.length
+ if (generalErrorCount > 0) {
+ toast.error(`${generalErrorCount}개 항목 저장에 실패했습니다.`)
}
} catch (error) {
console.error("Batch save error:", error)
@@ -352,7 +369,14 @@ export function VendorPoolTable({ data, pageCount, onRefresh }: VendorPoolTableP
}
} catch (error) {
console.error("빈 행 저장 실패:", error)
- toast.error("저장 중 오류가 발생했습니다.")
+
+ // Unique 제약 조건 위반 감지
+ const errorMessage = error instanceof Error ? error.message : String(error);
+ if (errorMessage === 'DUPLICATE_VENDOR_POOL') {
+ toast.error(`중복된 항목입니다. (공사부문: ${finalData.constructionSector}, H/T: ${finalData.htDivision}, 자재그룹코드: ${finalData.materialGroupCode}, 협력업체명: ${finalData.vendorName})`)
+ } else {
+ toast.error("저장 중 오류가 발생했습니다.")
+ }
} finally {
setIsSaving(false)
}
@@ -448,6 +472,25 @@ export function VendorPoolTable({ data, pageCount, onRefresh }: VendorPoolTableP
const advancedFilterFields: DataTableAdvancedFilterField<VendorPoolItem>[] = [
{
+ id: "constructionSector",
+ label: "공사부문",
+ type: "select",
+ options: [
+ { label: "조선", value: "조선" },
+ { label: "해양", value: "해양" },
+ ]
+ },
+ {
+ id: "htDivision",
+ label: "H/T구분",
+ type: "select",
+ options: [
+ { label: "H", value: "H" },
+ { label: "T", value: "T" },
+ { label: "공통", value: "공통" },
+ ]
+ },
+ {
id: "designCategoryCode",
label: "설계기능코드",
type: "text",