diff --git a/src/contexts/budget/hooks/useBudgetGoalUpdate.ts b/src/contexts/budget/hooks/useBudgetGoalUpdate.ts index c172f45..4ab6b4c 100644 --- a/src/contexts/budget/hooks/useBudgetGoalUpdate.ts +++ b/src/contexts/budget/hooks/useBudgetGoalUpdate.ts @@ -31,17 +31,18 @@ export const useBudgetGoalUpdate = ( return; } - // 주간 예산을 월간 예산과 동일하게 설정 + // 주간 예산을 월간 예산과 동일하게 설정하기 위한 타입 변환 + let updatedType: BudgetPeriod = type; if (type === 'weekly') { console.log(`주간 예산(${amount})을 월간 예산으로 직접 설정`); - type = 'monthly'; + updatedType = 'monthly'; } // 현재 최신 예산 데이터 로드 (다른 곳에서 변경되었을 수 있음) const currentBudgetData = safelyLoadBudgetData(); - // 예산 데이터 업데이트 - 입력된 타입 그대로 사용 - const updatedBudgetData = calculateUpdatedBudgetData(currentBudgetData, type, amount); + // 예산 데이터 업데이트 - 변환된 타입 사용 + const updatedBudgetData = calculateUpdatedBudgetData(currentBudgetData, updatedType, amount); console.log('새 예산 데이터 계산됨:', updatedBudgetData); // 상태 및 스토리지 둘 다 업데이트 diff --git a/src/contexts/budget/hooks/useExtendedBudgetUpdate.ts b/src/contexts/budget/hooks/useExtendedBudgetUpdate.ts index 3221344..011f2a9 100644 --- a/src/contexts/budget/hooks/useExtendedBudgetUpdate.ts +++ b/src/contexts/budget/hooks/useExtendedBudgetUpdate.ts @@ -17,15 +17,16 @@ export const useExtendedBudgetUpdate = ( ) => { console.log('확장 예산 업데이트 시작:', type, amount, newCategoryBudgets); - // 항상 주간 예산을 월간 예산과 동일하게 설정 + // 항상 주간 예산을 월간 예산과 동일하게 설정하기 위한 타입 변환 + let updatedType: BudgetPeriod = type; if (type === 'weekly') { console.log(`주간 예산(${amount})을 월간 예산으로 직접 사용`); - type = 'monthly'; + updatedType = 'monthly'; } // 예산 업데이트 - console.log(`예산 업데이트: 타입=${type}, 금액=${amount}`); - handleBudgetUpdate(type, amount); + console.log(`예산 업데이트: 타입=${updatedType}, 금액=${amount}`); + handleBudgetUpdate(updatedType, amount); // 카테고리 예산 업데이트 (제공된 경우) if (newCategoryBudgets) {