Fix data display issues

Addresses issues where budget and expense data were not displaying correctly on the summary cards, category bar graph, and transaction/analytics pages. Also fixes a bug where data was disappearing after input.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 06:46:45 +00:00
parent 16c17f0257
commit f3edf5fa20
8 changed files with 126 additions and 78 deletions

View File

@@ -33,6 +33,7 @@ export const saveBudgetDataToStorage = (budgetData: BudgetData): void => {
console.log('예산 데이터 저장 완료');
// 스토리지 이벤트 수동 트리거 (동일 창에서도 감지하기 위함)
window.dispatchEvent(new Event('budgetDataUpdated'));
window.dispatchEvent(new StorageEvent('storage', {
key: 'budgetData'
}));
@@ -51,6 +52,9 @@ export const clearAllBudgetData = (): void => {
const initialData = getInitialBudgetData();
saveBudgetDataToStorage(initialData);
console.log('예산 데이터가 초기화되었습니다.');
// 스토리지 이벤트 수동 트리거
window.dispatchEvent(new Event('budgetDataUpdated'));
} catch (error) {
console.error('예산 데이터 삭제 오류:', error);
}

View File

@@ -31,6 +31,7 @@ export const saveCategoryBudgetsToStorage = (categoryBudgets: Record<string, num
console.log('카테고리 예산 저장 완료:', categoryBudgets);
// 스토리지 이벤트 수동 트리거 (동일 창에서도 감지하기 위함)
window.dispatchEvent(new Event('categoryBudgetsUpdated'));
window.dispatchEvent(new StorageEvent('storage', {
key: 'categoryBudgets'
}));
@@ -48,6 +49,9 @@ export const clearAllCategoryBudgets = (): void => {
// 기본값으로 재설정
saveCategoryBudgetsToStorage(DEFAULT_CATEGORY_BUDGETS);
console.log('카테고리 예산이 초기화되었습니다.');
// 이벤트 발생
window.dispatchEvent(new Event('categoryBudgetsUpdated'));
} catch (error) {
console.error('카테고리 예산 삭제 오류:', error);
}

View File

@@ -8,7 +8,9 @@ export const loadTransactionsFromStorage = (): Transaction[] => {
try {
const storedTransactions = localStorage.getItem('transactions');
if (storedTransactions) {
return JSON.parse(storedTransactions);
const parsedData = JSON.parse(storedTransactions);
console.log('트랜잭션 로드 완료, 항목 수:', parsedData.length);
return parsedData;
}
} catch (error) {
console.error('트랜잭션 데이터 파싱 오류:', error);
@@ -25,6 +27,7 @@ export const saveTransactionsToStorage = (transactions: Transaction[]): void =>
console.log('트랜잭션 저장 완료, 항목 수:', transactions.length);
// 스토리지 이벤트 수동 트리거 (동일 창에서도 감지하기 위함)
window.dispatchEvent(new Event('transactionUpdated'));
window.dispatchEvent(new StorageEvent('storage', {
key: 'transactions'
}));
@@ -44,6 +47,7 @@ export const clearAllTransactions = (): void => {
console.log('모든 트랜잭션이 삭제되었습니다.');
// 스토리지 이벤트 수동 트리거
window.dispatchEvent(new Event('transactionUpdated'));
window.dispatchEvent(new StorageEvent('storage', {
key: 'transactions'
}));