엑셀 업로드 기능 개선

This commit is contained in:
kjs
2025-12-17 12:01:16 +09:00
parent 3d287bb883
commit 1995c3dca4
3 changed files with 43 additions and 18 deletions

View File

@@ -236,13 +236,23 @@ export const ExcelUploadModal: React.FC<ExcelUploadModalProps> = ({
}
};
// 자동 매핑
// 자동 매핑 - 컬럼명과 라벨 모두 비교
const handleAutoMapping = () => {
const newMappings = excelColumns.map((excelCol) => {
const matchedSystemCol = systemColumns.find(
(sysCol) => sysCol.name.toLowerCase() === excelCol.toLowerCase()
const normalizedExcelCol = excelCol.toLowerCase().trim();
// 1. 먼저 라벨로 매칭 시도
let matchedSystemCol = systemColumns.find(
(sysCol) => sysCol.label && sysCol.label.toLowerCase().trim() === normalizedExcelCol
);
// 2. 라벨로 매칭되지 않으면 컬럼명으로 매칭 시도
if (!matchedSystemCol) {
matchedSystemCol = systemColumns.find(
(sysCol) => sysCol.name.toLowerCase().trim() === normalizedExcelCol
);
}
return {
excelColumn: excelCol,
systemColumn: matchedSystemCol ? matchedSystemCol.name : null,
@@ -734,7 +744,14 @@ export const ExcelUploadModal: React.FC<ExcelUploadModalProps> = ({
}
>
<SelectTrigger className="h-8 text-xs sm:h-10 sm:text-sm">
<SelectValue placeholder="매핑 안함" />
<SelectValue placeholder="매핑 안함">
{mapping.systemColumn
? (() => {
const col = systemColumns.find(c => c.name === mapping.systemColumn);
return col?.label || mapping.systemColumn;
})()
: "매핑 안함"}
</SelectValue>
</SelectTrigger>
<SelectContent>
<SelectItem value="none" className="text-xs sm:text-sm">
@@ -746,7 +763,7 @@ export const ExcelUploadModal: React.FC<ExcelUploadModalProps> = ({
value={col.name}
className="text-xs sm:text-sm"
>
{col.name} ({col.type})
{col.label || col.name} ({col.type})
</SelectItem>
))}
</SelectContent>