Refactor: Split useBudgetState hook

The useBudgetState hook was split into smaller, more manageable files to improve code organization and maintainability.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 07:24:33 +00:00
parent 7c8e542912
commit 84553d4fee
5 changed files with 182 additions and 160 deletions

View File

@@ -0,0 +1,39 @@
import { useCallback } from 'react';
import { toast } from '@/components/ui/use-toast';
// 예산 데이터 리셋 훅
export const useBudgetReset = (
resetTransactions: () => void,
resetCategoryBudgets: () => void,
resetBudgetDataInternal: () => void
) => {
// 모든 데이터 리셋 함수
const resetBudgetData = useCallback(() => {
try {
console.log('BudgetContext에서 데이터 리셋 시작');
// 로컬 스토리지 초기화
resetTransactions();
resetCategoryBudgets();
resetBudgetDataInternal();
console.log('BudgetContext에서 데이터 리셋 완료');
// 토스트 알림
toast({
title: "모든 데이터 초기화",
description: "예산과 지출 내역이 모두 초기화되었습니다.",
});
} catch (error) {
console.error('데이터 초기화 중 오류:', error);
toast({
title: "초기화 실패",
description: "데이터를 초기화하는 중 오류가 발생했습니다.",
variant: "destructive"
});
}
}, [resetTransactions, resetCategoryBudgets, resetBudgetDataInternal]);
return { resetBudgetData };
};