Fix budget update issues
Addresses delayed notifications and data loss after budget updates and page transitions.
This commit is contained in:
@@ -34,6 +34,7 @@ const BudgetInputCard: React.FC<BudgetGoalProps> = ({
|
||||
return numericValue.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||
};
|
||||
|
||||
// 초기값 변경시 입력 필드 값 업데이트
|
||||
useEffect(() => {
|
||||
setBudgetInputs({
|
||||
daily: initialBudgets.daily > 0 ? initialBudgets.daily.toString() : '',
|
||||
@@ -53,9 +54,21 @@ const BudgetInputCard: React.FC<BudgetGoalProps> = ({
|
||||
|
||||
const handleSave = () => {
|
||||
const amount = parseInt(budgetInputs[selectedTab].replace(/,/g, ''), 10) || 0;
|
||||
onSave(selectedTab, amount);
|
||||
// Close the collapsible after saving
|
||||
if (amount <= 0) {
|
||||
return; // 0 이하의 금액은 저장하지 않음
|
||||
}
|
||||
|
||||
// 즉시 입력 필드를 업데이트하여 사용자에게 피드백 제공
|
||||
setBudgetInputs(prev => ({
|
||||
...prev,
|
||||
[selectedTab]: amount.toString()
|
||||
}));
|
||||
|
||||
// 즉시 콜랩시블을 닫아 사용자에게 완료 피드백 제공
|
||||
setIsOpen(false);
|
||||
|
||||
// 예산 저장
|
||||
onSave(selectedTab, amount);
|
||||
};
|
||||
|
||||
// 비어있으면 빈 문자열을, 그렇지 않으면 포맷팅된 문자열을 반환
|
||||
|
||||
Reference in New Issue
Block a user