Fix budget update issue

Addresses an issue where budget updates were not being applied correctly.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-22 11:20:58 +00:00
parent b81187a4d8
commit 0702145431
4 changed files with 11 additions and 7 deletions

View File

@@ -50,6 +50,7 @@ const BudgetProgressCard: React.FC<BudgetProgressCardProps> = ({
// 컴포넌트 마운트 시 월간 탭을 기본으로 설정
useEffect(() => {
if (selectedTab !== 'monthly') {
console.log("탭을 monthly로 강제 설정");
setSelectedTab('monthly');
}
}, []);
@@ -112,7 +113,7 @@ const BudgetProgressCard: React.FC<BudgetProgressCardProps> = ({
data={budgetData.daily}
formatCurrency={formatCurrency}
calculatePercentage={calculatePercentage}
onSaveBudget={(amount, categoryBudgets) => onSaveBudget('daily', amount, categoryBudgets)}
onSaveBudget={(amount, categoryBudgets) => onSaveBudget('monthly', amount, categoryBudgets)}
/>
</TabsContent>
@@ -121,7 +122,7 @@ const BudgetProgressCard: React.FC<BudgetProgressCardProps> = ({
data={budgetData.weekly}
formatCurrency={formatCurrency}
calculatePercentage={calculatePercentage}
onSaveBudget={(amount, categoryBudgets) => onSaveBudget('weekly', amount, categoryBudgets)}
onSaveBudget={(amount, categoryBudgets) => onSaveBudget('monthly', amount, categoryBudgets)}
/>
</TabsContent>

View File

@@ -51,7 +51,8 @@ const BudgetTabContent: React.FC<BudgetTabContentProps> = ({
// 월간 예산 모드를 명시적으로 로깅
React.useEffect(() => {
console.log('BudgetTabContent 렌더링: 월간 예산 모드');
}, []);
console.log('현재 예산 데이터:', data);
}, [data]);
return (
<div>

View File

@@ -17,10 +17,11 @@ export const useExtendedBudgetUpdate = (
) => {
console.log('확장 예산 업데이트 시작:', type, amount, newCategoryBudgets);
// 카테고리 예산 입력 폼에서 호출된 경우, type이 없으면 monthly로 설정
const budgetType = type || 'monthly';
// 무조건 monthly로 설정 - 이게 핵심 수정 부분
const budgetType = 'monthly';
// 기본 예산 목표 업데이트 - 항상 월간 예산 우선
// 이제 항상 월간 예산으로 업데이트
console.log(`예산 업데이트: 타입을 '${budgetType}'로 강제 변환, 금액=${amount}`);
handleBudgetUpdate(budgetType, amount);
// 카테고리 예산 업데이트 (제공된 경우)

View File

@@ -110,12 +110,13 @@ export const useBudgetTabContent = ({
// 총액이 0이 아닐 때만 저장 처리
if (totalBudget > 0) {
// 명시적으로 월간 예산으로 설정 - 'monthly' 타입으로 전달
// 명시적으로 월간 예산으로 설정 - 항상 월간 예산만 저장
onSaveBudget(totalBudget, updatedCategoryBudgets);
setShowBudgetInput(false);
// 이벤트 발생 추가 (데이터 저장 후 즉시 UI 업데이트를 위해)
setTimeout(() => {
console.log('예산 데이터 저장 후 이벤트 발생');
window.dispatchEvent(new Event('budgetDataUpdated'));
}, 200);
} else {