Reset budget and transaction data
Resets all budget data and transaction history to provide a clean slate.
This commit is contained in:
@@ -24,6 +24,8 @@ export const saveTransactionsToStorage = (transactions: Transaction[]): void =>
|
||||
// 모든 트랜잭션 삭제
|
||||
export const clearAllTransactions = (): void => {
|
||||
localStorage.removeItem('transactions');
|
||||
// 빈 배열을 저장하여 확실히 초기화
|
||||
localStorage.setItem('transactions', JSON.stringify([]));
|
||||
};
|
||||
|
||||
// 카테고리 예산 불러오기
|
||||
@@ -90,8 +92,21 @@ export const clearAllBudgetData = (): void => {
|
||||
|
||||
// 모든 데이터 초기화 (첫 로그인 상태)
|
||||
export const resetAllData = (): void => {
|
||||
// 모든 관련 데이터 키 목록
|
||||
const dataKeys = [
|
||||
'transactions',
|
||||
'categoryBudgets',
|
||||
'budgetData',
|
||||
'budget',
|
||||
'hasVisitedBefore'
|
||||
];
|
||||
|
||||
// 모든 관련 데이터 키 삭제
|
||||
dataKeys.forEach(key => localStorage.removeItem(key));
|
||||
|
||||
// 기본 데이터로 초기화
|
||||
clearAllTransactions();
|
||||
clearAllCategoryBudgets();
|
||||
clearAllBudgetData();
|
||||
localStorage.removeItem('hasVisitedBefore');
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user