Clear persistent data

Clear data that persists and is displayed in monthly graphs for analysis.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 22:59:37 +00:00
parent 829b7af80d
commit 2ba8fdc31b
3 changed files with 47 additions and 39 deletions

View File

@@ -12,42 +12,8 @@ export const loadTransactionsFromStorage = (): Transaction[] => {
// 기본 샘플 데이터 생성
export const createSampleTransactions = (selectedMonth: string): Transaction[] => {
return [{
id: '1',
title: '식료품 구매',
amount: 25000,
date: `${selectedMonth} 25일, 12:30 PM`,
category: '식비',
type: 'expense'
}, {
id: '2',
title: '주유소',
amount: 50000,
date: `${selectedMonth} 24일, 3:45 PM`,
category: '교통비',
type: 'expense'
}, {
id: '4',
title: '생필품 구매',
amount: 35000,
date: `${selectedMonth} 18일, 6:00 AM`,
category: '생활비',
type: 'expense'
}, {
id: '5',
title: '월세',
amount: 650000,
date: `${selectedMonth} 15일, 10:00 AM`,
category: '생활비',
type: 'expense'
}, {
id: '6',
title: '식당',
amount: 15500,
date: `${selectedMonth} 12일, 2:15 PM`,
category: '식비',
type: 'expense'
}];
// 샘플 데이터는 생성하지 않고 빈 배열 반환 (초기 상태에서는 데이터가 없어야 함)
return [];
};
// 트랜잭션 데이터 저장하기
@@ -64,3 +30,19 @@ export const loadBudgetFromStorage = (): number => {
}
return 1000000; // 기본 예산
};
// 모든 데이터 완전히 초기화
export const resetAllStorageData = (): void => {
// 트랜잭션 초기화
localStorage.removeItem('transactions');
localStorage.setItem('transactions', JSON.stringify([]));
// 월별 지출 데이터 초기화
localStorage.removeItem('monthlyExpenses');
// 예산 초기화
localStorage.removeItem('budget');
console.log('모든 저장소 데이터가 초기화되었습니다.');
};