Fix budget display issue
The budget amount was displaying incorrectly, showing three times the actual value. This commit fixes the issue.
This commit is contained in:
@@ -52,15 +52,22 @@ const BudgetTabContent: React.FC<BudgetTabContentProps> = ({
|
||||
|
||||
// 카테고리별 예산 합계 계산
|
||||
const calculateTotalBudget = () => {
|
||||
return Object.values(categoryBudgets).reduce((sum, value) => sum + value, 0);
|
||||
const total = Object.values(categoryBudgets).reduce((sum, value) => sum + value, 0);
|
||||
console.log('카테고리 예산 총합:', total, categoryBudgets);
|
||||
return total;
|
||||
};
|
||||
|
||||
// 카테고리 예산 저장
|
||||
const handleSaveCategoryBudgets = () => {
|
||||
const totalBudget = calculateTotalBudget();
|
||||
console.log('카테고리 예산 저장 및 총 예산 설정:', totalBudget, categoryBudgets);
|
||||
onSaveBudget(totalBudget, categoryBudgets);
|
||||
setShowBudgetInput(false);
|
||||
// 총액이 0이 아닐 때만 저장 처리
|
||||
if (totalBudget > 0) {
|
||||
onSaveBudget(totalBudget, categoryBudgets);
|
||||
setShowBudgetInput(false);
|
||||
} else {
|
||||
alert('예산을 입력해주세요.');
|
||||
}
|
||||
};
|
||||
|
||||
// 기존 카테고리 예산 불러오기
|
||||
@@ -70,7 +77,9 @@ const BudgetTabContent: React.FC<BudgetTabContentProps> = ({
|
||||
try {
|
||||
const storedCategoryBudgets = localStorage.getItem('categoryBudgets');
|
||||
if (storedCategoryBudgets) {
|
||||
setCategoryBudgets(JSON.parse(storedCategoryBudgets));
|
||||
const parsedBudgets = JSON.parse(storedCategoryBudgets);
|
||||
console.log('저장된 카테고리 예산 불러옴:', parsedBudgets);
|
||||
setCategoryBudgets(parsedBudgets);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('카테고리 예산 불러오기 오류:', error);
|
||||
|
||||
Reference in New Issue
Block a user