Fix budget display and category issues

- Fix budget amount not displaying outside the homepage.
- Remove unexpected categories and revert to the original 3 categories.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 08:17:02 +00:00
parent 32a6832b84
commit 79d38f1fc1
5 changed files with 50 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ import {
updateTransactionInSupabase,
deleteTransactionFromSupabase
} from '@/utils/supabaseTransactionUtils';
import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
// 월 이름 재노출
export { MONTHS_KR };
@@ -52,8 +53,20 @@ export const useTransactions = () => {
// 로컬 스토리지에서 트랜잭션 데이터 가져오기
const localData = loadTransactionsFromStorage();
// 지원되는 카테고리로 필터링
const filteredData = localData.map(transaction => {
// 트랜잭션의 카테고리가 현재 지원되는 카테고리가 아니면 '기타'로 변경
if (transaction.type === 'expense' && !EXPENSE_CATEGORIES.includes(transaction.category)) {
return {
...transaction,
category: '생활비' // 기본값으로 '생활비' 사용
};
}
return transaction;
});
// 로컬 데이터가 있으면 사용
setTransactions(localData);
setTransactions(filteredData);
// 예산 가져오기
const budget = loadBudgetFromStorage();