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:
@@ -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);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const useExtendedBudgetUpdate = (
|
||||
const updatedBudgetData = calculateUpdatedBudgetData(budgetData, 'monthly', totalAmount);
|
||||
|
||||
// 각 기간별 예산 업데이트
|
||||
handleBudgetGoalUpdate('monthly', updatedBudgetData.monthly.targetAmount);
|
||||
handleBudgetGoalUpdate('monthly', totalAmount);
|
||||
} else {
|
||||
// 카테고리 예산이 없는 경우, 기존 로직 사용
|
||||
handleBudgetGoalUpdate(type, amount);
|
||||
|
||||
Reference in New Issue
Block a user