Prevent duplicate toast notifications

The application was displaying duplicate toast notifications due to events being triggered multiple times. This commit prevents duplicate notifications.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 09:38:39 +00:00
parent 2a70aa18b7
commit 662cacbc99
7 changed files with 150 additions and 65 deletions

View File

@@ -5,7 +5,7 @@ import { Check, ChevronDown, ChevronUp, Calculator } from 'lucide-react';
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
import BudgetProgress from './BudgetProgress';
import CategoryBudgetInputs from './CategoryBudgetInputs';
import { toast } from '@/components/ui/use-toast';
import { toast } from '@/hooks/useToast.wrapper'; // 래퍼 함수 사용
import { EXPENSE_CATEGORIES } from '@/constants/categoryIcons';
interface BudgetData {
@@ -60,13 +60,23 @@ const BudgetTabContent: React.FC<BudgetTabContentProps> = ({
// Calculate total from all categories
const totalAmount = Object.values(categoryBudgets).reduce((sum, value) => sum + value, 0);
// 버튼 중복 클릭 방지를 위해 비활성화 처리 (setTimeout 사용)
const button = document.querySelector('button[type="button"]') as HTMLButtonElement;
if (button) {
button.disabled = true;
setTimeout(() => {
button.disabled = false;
}, 1000);
}
// 카테고리 예산도 함께 전달합니다
onSaveBudget(totalAmount, categoryBudgets);
toast({
title: "예산 설정 완료",
description: "카테고리별 예산이 성공적으로 저장되었습니다."
});
// 단일 토스트만 표시하고 즉시 패널 닫음
setIsOpen(false);
// 토스트는 이벤트 발생 후 처리되므로 여기서는 호출하지 않음
// 이 함수에서 직접 toast 호출하지 않고 budgetStorage에서 처리되도록 함
};
// Format with commas for display