fix: 품목기준관리 타입 에러 및 무한 로딩 버그 수정

- 55개 타입 에러 수정 (MasterOption/UnitOption 타입 통일)
- 다이얼로그 컴포넌트 import 누락 수정 (15개)
- useInitialDataLoading 무한 로딩 버그 수정 (useRef 적용)
- 미사용 변수 _ prefix 처리
- 미사용 ItemMasterDialogs export 제거

🤖 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:17:25 +09:00
parent 1664599cd5
commit 028932d815
5 changed files with 66 additions and 53 deletions

View File

@@ -1,6 +1,6 @@
'use client';
import { useState, useEffect, useCallback } from 'react';
import { useState, useEffect, useCallback, useRef } from 'react';
import { useItemMaster } from '@/contexts/ItemMasterContext';
import { itemMasterApi } from '@/lib/api/item-master';
import { getErrorMessage, ApiError } from '@/lib/api/error-handler';
@@ -15,7 +15,10 @@ import {
} from '@/lib/api/transformers';
import { toast } from 'sonner';
import type { CustomTab } from './useTabManagement';
import type { UnitOption } from './useAttributeManagement';
import type { MasterOption } from '../types';
// 타입 alias
type UnitOption = MasterOption;
export interface UseInitialDataLoadingReturn {
isInitialLoading: boolean;
@@ -43,6 +46,9 @@ export function useInitialDataLoading({
const [isInitialLoading, setIsInitialLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
// 초기 로딩이 이미 실행되었는지 추적하는 ref
const hasInitialLoadRun = useRef(false);
const loadInitialData = useCallback(async () => {
try {
setIsInitialLoading(true);
@@ -138,9 +144,15 @@ export function useInitialDataLoading({
setUnitOptions,
]);
// 초기 로딩은 한 번만 실행 (의존성 배열의 함수들이 불안정해도 무한 루프 방지)
useEffect(() => {
if (hasInitialLoadRun.current) {
return;
}
hasInitialLoadRun.current = true;
loadInitialData();
}, [loadInitialData]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return {
isInitialLoading,