feat: 품목기준관리 Zustand store 연동

- useInitialDataLoading에서 Zustand initFromApi() 호출 추가
- Context와 Zustand 병행 운영 구조 구축
- Zustand 초기화 실패 시 Context fallback 처리
- 점진적 마이그레이션 기반 마련

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
byeongcheolryu
2025-12-24 16:31:44 +09:00
parent 028932d815
commit 172d06b697
2 changed files with 108 additions and 82 deletions

View File

@@ -2,6 +2,7 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { useItemMaster } from '@/contexts/ItemMasterContext';
import { useItemMasterStore } from '@/stores/item-master/useItemMasterStore';
import { itemMasterApi } from '@/lib/api/item-master';
import { getErrorMessage, ApiError } from '@/lib/api/error-handler';
import {
@@ -43,6 +44,9 @@ export function useInitialDataLoading({
loadIndependentFields,
} = useItemMaster();
// ✅ 2025-12-24: Zustand store 연동
const initFromApi = useItemMasterStore((state) => state.initFromApi);
const [isInitialLoading, setIsInitialLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -54,6 +58,16 @@ export function useInitialDataLoading({
setIsInitialLoading(true);
setError(null);
// ✅ Zustand store 초기화 (정규화된 상태로 저장)
// Context와 병행 운영 - 점진적 마이그레이션
try {
await initFromApi();
console.log('✅ [Zustand] Store initialized');
} catch (zustandError) {
// Zustand 초기화 실패해도 Context로 fallback
console.warn('⚠️ [Zustand] Init failed, falling back to Context:', zustandError);
}
const data = await itemMasterApi.init();
// 1. 페이지 데이터 로드 (섹션이 이미 포함되어 있음)