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.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import BudgetProgressCard from '@/components/BudgetProgressCard';
|
import BudgetProgressCard from '@/components/BudgetProgressCard';
|
||||||
import BudgetCategoriesSection from '@/components/BudgetCategoriesSection';
|
import BudgetCategoriesSection from '@/components/BudgetCategoriesSection';
|
||||||
@@ -46,10 +47,15 @@ const HomeContent: React.FC<HomeContentProps> = ({
|
|||||||
updateTransaction,
|
updateTransaction,
|
||||||
getCategorySpending
|
getCategorySpending
|
||||||
}) => {
|
}) => {
|
||||||
|
// getCategorySpending 함수의 반환값을 바로 사용하지 말고, 변수에 할당하여 사용
|
||||||
|
const categorySpendingData = getCategorySpending();
|
||||||
|
const hasAnySpending = Array.isArray(categorySpendingData) &&
|
||||||
|
categorySpendingData.some(cat => cat.current > 0 || cat.total > 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="pb-[50px]">
|
<div className="pb-[50px]">
|
||||||
{getCategorySpending().some(cat => cat.current > 0 || cat.total > 0) ? (
|
{hasAnySpending ? (
|
||||||
<BudgetCategoriesSection categories={getCategorySpending()} />
|
<BudgetCategoriesSection categories={categorySpendingData} />
|
||||||
) : (
|
) : (
|
||||||
<EmptyState />
|
<EmptyState />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { Transaction } from '../types';
|
import { Transaction } from '../types';
|
||||||
import { calculateCategorySpending } from '../budgetUtils';
|
import { calculateCategorySpending } from '../utils/categoryUtils';
|
||||||
|
|
||||||
// 카테고리별 지출 계산 훅
|
// 카테고리별 지출 계산 훅
|
||||||
export const useCategorySpending = (
|
export const useCategorySpending = (
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { useWelcomeDialog } from '@/hooks/useWelcomeDialog';
|
|||||||
import { useDataInitialization } from '@/hooks/useDataInitialization';
|
import { useDataInitialization } from '@/hooks/useDataInitialization';
|
||||||
import { useIsMobile } from '@/hooks/use-mobile';
|
import { useIsMobile } from '@/hooks/use-mobile';
|
||||||
import useNotifications from '@/hooks/useNotifications';
|
import useNotifications from '@/hooks/useNotifications';
|
||||||
|
import SafeAreaContainer from '@/components/SafeAreaContainer';
|
||||||
|
|
||||||
// 메인 컴포넌트
|
// 메인 컴포넌트
|
||||||
const Index = () => {
|
const Index = () => {
|
||||||
@@ -149,7 +150,7 @@ const Index = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-neuro-background pb-24">
|
<SafeAreaContainer className="min-h-screen bg-neuro-background pb-24">
|
||||||
<div className="max-w-md mx-auto px-6">
|
<div className="max-w-md mx-auto px-6">
|
||||||
<Header />
|
<Header />
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ const Index = () => {
|
|||||||
|
|
||||||
{/* 첫 사용자 안내 팝업 */}
|
{/* 첫 사용자 안내 팝업 */}
|
||||||
<WelcomeDialog open={showWelcome} onClose={handleCloseWelcome} />
|
<WelcomeDialog open={showWelcome} onClose={handleCloseWelcome} />
|
||||||
</div>
|
</SafeAreaContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user