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.
18 lines
533 B
TypeScript
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 };
|
|
};
|