Refactor useBudgetState into smaller files
Refactors the `useBudgetState.ts` file into smaller, more manageable files to improve code organization and maintainability. No functionality is changed.
This commit is contained in:
17
src/contexts/budget/hooks/useCategorySpending.ts
Normal file
17
src/contexts/budget/hooks/useCategorySpending.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import { useCallback } from 'react';
|
||||
import { Transaction } from '../types';
|
||||
import { calculateCategorySpending } from '../budgetUtils';
|
||||
|
||||
// 카테고리별 지출 계산 훅
|
||||
export const useCategorySpending = (
|
||||
transactions: Transaction[],
|
||||
categoryBudgets: Record<string, number>
|
||||
) => {
|
||||
// 카테고리별 지출 계산
|
||||
const getCategorySpending = useCallback(() => {
|
||||
return calculateCategorySpending(transactions, categoryBudgets);
|
||||
}, [transactions, categoryBudgets]);
|
||||
|
||||
return { getCategorySpending };
|
||||
};
|
||||
Reference in New Issue
Block a user