Files
zellyy-finance/src/contexts/budget/hooks/useCategorySpending.ts
gpt-engineer-app[bot] 8168d4b645 Fix type error in HomeContent
The `getCategorySpending` function was not returning an array, causing a type error when used with the `some` method in the `HomeContent` component. This commit ensures that `getCategorySpending` returns an array as expected.
2025-03-23 10:26:51 +00:00

18 lines
533 B
TypeScript

import { useCallback } from 'react';
import { Transaction } from '../types';
import { calculateCategorySpending } from '../utils/categoryUtils';
// 카테고리별 지출 계산 훅
export const useCategorySpending = (
transactions: Transaction[],
categoryBudgets: Record<string, number>
) => {
// 카테고리별 지출 계산
const getCategorySpending = useCallback(() => {
return calculateCategorySpending(transactions, categoryBudgets);
}, [transactions, categoryBudgets]);
return { getCategorySpending };
};