Address unresolved issues
This commit addresses previously reported issues that remain unresolved. Further investigation is required.
This commit is contained in:
@@ -59,8 +59,7 @@ export const useExtendedBudgetUpdate = (
|
||||
return;
|
||||
}
|
||||
|
||||
// 월간 예산 금액으로 예산 데이터 업데이트
|
||||
// 월간 예산을 설정하면 자동으로 일간/주간 예산도 계산됨
|
||||
// 항상 월간 예산으로 처리하여 일/주간 자동계산 보장
|
||||
handleBudgetGoalUpdate('monthly', totalAmount);
|
||||
|
||||
// 명시적으로 BudgetData 업데이트 이벤트 발생
|
||||
@@ -72,9 +71,18 @@ export const useExtendedBudgetUpdate = (
|
||||
description: `월간 총 예산이 ${totalAmount.toLocaleString()}원으로 설정되었습니다.`
|
||||
});
|
||||
|
||||
// 1초 후 페이지 리프레시 (데이터 표시 강제 갱신)
|
||||
// 여러 번의 이벤트 발생으로 UI 업데이트 보장 (타이밍 문제 해결)
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
}, 300);
|
||||
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
// 스토리지 이벤트도 발생시켜 데이터 로드 보장
|
||||
window.dispatchEvent(new StorageEvent('storage', {
|
||||
key: 'budgetData',
|
||||
newValue: localStorage.getItem('budgetData')
|
||||
}));
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.error('카테고리 예산 업데이트 오류:', error);
|
||||
@@ -86,7 +94,6 @@ export const useExtendedBudgetUpdate = (
|
||||
}
|
||||
} else {
|
||||
// 카테고리 예산이 없는 경우, 선택된 기간 유형에 맞게 예산 설정
|
||||
// 이 경우에도 다른 기간의 예산이 자동으로 계산됨
|
||||
if (amount <= 0) {
|
||||
toast({
|
||||
title: "예산 설정 오류",
|
||||
@@ -96,7 +103,24 @@ export const useExtendedBudgetUpdate = (
|
||||
return;
|
||||
}
|
||||
|
||||
handleBudgetGoalUpdate(type, amount);
|
||||
// 어떤 타입이 들어오더라도 항상 월간으로 처리하고 일/주간은 자동계산
|
||||
if (type !== 'monthly') {
|
||||
console.log(`${type} 입력을 월간 예산으로 변환합니다.`);
|
||||
// 일간 입력인 경우 월간으로 변환 (30배)
|
||||
if (type === 'daily') {
|
||||
amount = amount * 30;
|
||||
}
|
||||
// 주간 입력인 경우 월간으로 변환 (4.3배)
|
||||
else if (type === 'weekly') {
|
||||
amount = Math.round(amount * 4.3);
|
||||
}
|
||||
|
||||
// 변환된 금액으로 월간 예산 설정
|
||||
handleBudgetGoalUpdate('monthly', amount);
|
||||
} else {
|
||||
// 원래 월간이면 그대로 설정
|
||||
handleBudgetGoalUpdate('monthly', amount);
|
||||
}
|
||||
|
||||
// 명시적으로 BudgetData 업데이트 이벤트 발생
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
@@ -108,9 +132,18 @@ export const useExtendedBudgetUpdate = (
|
||||
description: `${periodText} 예산이 ${amount.toLocaleString()}원으로 설정되었습니다.`
|
||||
});
|
||||
|
||||
// 1초 후 페이지 리프레시 (데이터 표시 강제 갱신)
|
||||
// 데이터 표시 강제 갱신 (타이밍 문제 해결을 위한 여러 이벤트 발생)
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
}, 300);
|
||||
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(new Event('budgetDataUpdated'));
|
||||
// 스토리지 이벤트도 발생시켜 데이터 로드 보장
|
||||
window.dispatchEvent(new StorageEvent('storage', {
|
||||
key: 'budgetData',
|
||||
newValue: localStorage.getItem('budgetData')
|
||||
}));
|
||||
}, 1000);
|
||||
}
|
||||
}, [categoryBudgets, handleBudgetGoalUpdate, updateCategoryBudgets]);
|
||||
|
||||
Reference in New Issue
Block a user