Reset budget and transactions
Resets budget data and transaction history as if the user is logging in for the first time.
This commit is contained in:
@@ -21,6 +21,11 @@ export const saveTransactionsToStorage = (transactions: Transaction[]): void =>
|
||||
localStorage.setItem('transactions', JSON.stringify(transactions));
|
||||
};
|
||||
|
||||
// 모든 트랜잭션 삭제
|
||||
export const clearAllTransactions = (): void => {
|
||||
localStorage.removeItem('transactions');
|
||||
};
|
||||
|
||||
// 카테고리 예산 불러오기
|
||||
export const loadCategoryBudgetsFromStorage = (): Record<string, number> => {
|
||||
const storedCategoryBudgets = localStorage.getItem('categoryBudgets');
|
||||
@@ -43,6 +48,13 @@ export const saveCategoryBudgetsToStorage = (categoryBudgets: Record<string, num
|
||||
localStorage.setItem('categoryBudgets', JSON.stringify(categoryBudgets));
|
||||
};
|
||||
|
||||
// 모든 카테고리 예산 삭제
|
||||
export const clearAllCategoryBudgets = (): void => {
|
||||
localStorage.removeItem('categoryBudgets');
|
||||
// 기본값으로 재설정
|
||||
saveCategoryBudgetsToStorage(DEFAULT_CATEGORY_BUDGETS);
|
||||
};
|
||||
|
||||
// 예산 데이터 불러오기
|
||||
export const loadBudgetDataFromStorage = (): BudgetData => {
|
||||
const storedBudgetData = localStorage.getItem('budgetData');
|
||||
@@ -67,3 +79,19 @@ export const loadBudgetDataFromStorage = (): BudgetData => {
|
||||
export const saveBudgetDataToStorage = (budgetData: BudgetData): void => {
|
||||
localStorage.setItem('budgetData', JSON.stringify(budgetData));
|
||||
};
|
||||
|
||||
// 모든 예산 데이터 삭제
|
||||
export const clearAllBudgetData = (): void => {
|
||||
localStorage.removeItem('budgetData');
|
||||
// 기본값으로 재설정
|
||||
const initialData = getInitialBudgetData();
|
||||
saveBudgetDataToStorage(initialData);
|
||||
};
|
||||
|
||||
// 모든 데이터 초기화 (첫 로그인 상태)
|
||||
export const resetAllData = (): void => {
|
||||
clearAllTransactions();
|
||||
clearAllCategoryBudgets();
|
||||
clearAllBudgetData();
|
||||
localStorage.removeItem('hasVisitedBefore');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user