fix: 카테고리 매핑 로딩 타이밍 개선
- loading 의존성 제거 (불필요한 재로드 방지) - columnMeta 길이 변화로 매핑 로드 트리거 - 매핑 로드 전후 상태 디버깅 로그 추가 - categoryMappings 빈 객체 문제 해결
This commit is contained in:
parent
f53a818f2f
commit
4affe623a5
|
|
@ -459,15 +459,18 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
const loadCategoryMappings = async () => {
|
||||
if (!tableConfig.selectedTable) return;
|
||||
|
||||
// 로딩 중에는 매핑 로드하지 않음 (데이터 로드 완료 후에만 실행)
|
||||
if (loading) return;
|
||||
|
||||
// columnMeta가 비어있으면 대기
|
||||
const columnMetaKeys = Object.keys(columnMeta || {});
|
||||
if (columnMetaKeys.length === 0) {
|
||||
console.log("⏳ [TableList] columnMeta 로딩 대기 중...");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("🚀 [TableList] 카테고리 매핑 로드 트리거:", {
|
||||
table: tableConfig.selectedTable,
|
||||
columnMetaKeys,
|
||||
dataLength: data.length,
|
||||
});
|
||||
|
||||
try {
|
||||
const categoryColumns = Object.entries(columnMeta)
|
||||
|
|
@ -514,15 +517,21 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
}
|
||||
|
||||
console.log("📊 [TableList] 전체 카테고리 매핑:", mappings);
|
||||
console.log("🔄 [TableList] setCategoryMappings 호출 전:", categoryMappings);
|
||||
setCategoryMappings(mappings);
|
||||
setCategoryMappingsKey((prev) => prev + 1); // 리렌더링 트리거
|
||||
|
||||
// 상태 업데이트 확인을 위한 setTimeout
|
||||
setTimeout(() => {
|
||||
console.log("✅ [TableList] setCategoryMappings 호출 후 (비동기):", categoryMappings);
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
console.error("TableListComponent 카테고리 매핑 로드 실패:", error);
|
||||
}
|
||||
};
|
||||
|
||||
loadCategoryMappings();
|
||||
}, [tableConfig.selectedTable, columnMeta, loading]); // loading이 false가 될 때마다 갱신!
|
||||
}, [tableConfig.selectedTable, Object.keys(columnMeta || {}).length]); // columnMeta가 로드되면 실행!
|
||||
|
||||
// ========================================
|
||||
// 데이터 가져오기
|
||||
|
|
@ -1054,6 +1063,8 @@ export const TableListComponent: React.FC<TableListComponentProps> = ({
|
|||
categoryData,
|
||||
hasMapping: !!mapping,
|
||||
hasCategoryData: !!categoryData,
|
||||
allCategoryMappings: categoryMappings, // 전체 매핑 확인
|
||||
categoryMappingsKeys: Object.keys(categoryMappings),
|
||||
});
|
||||
|
||||
// 매핑 데이터가 있으면 라벨과 색상 사용, 없으면 코드값과 기본색상
|
||||
|
|
|
|||
Loading…
Reference in New Issue