Fix toast and data display issues

- Fixes an issue where toast notifications would not automatically dismiss.
- Addresses a problem where expense data was not displaying correctly on the transaction and analytics screens.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 08:34:58 +00:00
parent 1281156f05
commit fe669b0cfd
6 changed files with 68 additions and 19 deletions

View File

@@ -2,7 +2,7 @@
import { BudgetData, BudgetPeriod, CategoryBudget, Transaction } from './types';
import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
// 기본 데이터 상수 (기본값을 0으로 변경)
// 기본 데이터 상수 (기본값을 0으로 설정)
export const DEFAULT_CATEGORY_BUDGETS: Record<string, number> = {
식비: 0,
생활비: 0,
@@ -27,9 +27,22 @@ export const calculateCategorySpending = (
}
});
// 지원되는 카테고리가 없을 경우 기본값 설정
if (Object.keys(categorySpending).length === 0) {
EXPENSE_CATEGORIES.forEach(category => {
categorySpending[category] = 0;
});
}
expenseTransactions.forEach(t => {
if (t.category in categorySpending) {
categorySpending[t.category] += t.amount;
} else if (EXPENSE_CATEGORIES.includes(t.category)) {
// 지원되는 카테고리이지만 초기화되지 않은 경우
categorySpending[t.category] = t.amount;
} else {
// 지원되지 않는 카테고리는 '생활비'로 집계
categorySpending['생활비'] = (categorySpending['생활비'] || 0) + t.amount;
}
});
@@ -131,7 +144,7 @@ export const calculateSpentAmounts = (
// 이번 주 지출 계산 (단순화된 버전)
const weeklyExpenses = expenseTransactions.filter(t => {
if (t.date.includes('오늘') || t.date.includes('어제')) return true;
if (t.date.includes('오늘') || t.date.includes('어제') || t.date.includes('이번주')) return true;
return true;
});
const weeklySpent = weeklyExpenses.reduce((sum, t) => sum + t.amount, 0);