diff --git a/src/components/expenses/ExpenseForm.tsx b/src/components/expenses/ExpenseForm.tsx index 1c43526..b61c114 100644 --- a/src/components/expenses/ExpenseForm.tsx +++ b/src/components/expenses/ExpenseForm.tsx @@ -83,7 +83,6 @@ const ExpenseForm: React.FC = ({ onSubmit, onCancel, isSubmitt field.onChange(value)} - disabled={isSubmitting} /> )} diff --git a/src/components/security/DataResetSection.tsx b/src/components/security/DataResetSection.tsx index d9a583c..a39ca89 100644 --- a/src/components/security/DataResetSection.tsx +++ b/src/components/security/DataResetSection.tsx @@ -1,6 +1,5 @@ - import React, { useState } from 'react'; -import { Trash2 } from 'lucide-react'; +import { Trash2, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { useToast } from '@/hooks/useToast.wrapper'; import { useNavigate } from 'react-router-dom'; diff --git a/src/components/ui/use-toast.ts b/src/components/ui/use-toast.ts index d3da9e2..f888a93 100644 --- a/src/components/ui/use-toast.ts +++ b/src/components/ui/use-toast.ts @@ -1,4 +1,5 @@ -import { useToast, toast } from "@/hooks/use-toast"; +// useToast.wrapper.ts에서 수정된 toast 함수를 사용하도록 리디렉션 +import { useToast, toast } from "@/hooks/useToast.wrapper"; export { useToast, toast }; diff --git a/src/hooks/use-toast.ts b/src/hooks/use-toast.ts index bcbc4d7..b974e88 100644 --- a/src/hooks/use-toast.ts +++ b/src/hooks/use-toast.ts @@ -1,3 +1,4 @@ + import * as React from "react" import { ToastProps } from "@/components/ui/toast" @@ -68,22 +69,17 @@ export const useToast = () => { addToast, updateToast, dismissToast, + toast: (props: ToasterToast) => addToast(props), // toast 속성 추가 }; }; // 전역 토스트 함수에도 기본 지속 시간 적용 -export const toast = ({ - ...props -}: ToastActionElement & { - title?: React.ReactNode; - description?: React.ReactNode; - duration?: number; -}) => { +export const toast = (props: Omit) => { // 기본 지속 시간을 적용 const toastWithDefaults = { ...props, duration: props.duration || DEFAULT_TOAST_DURATION, }; - return toastStore.getState().addToast(toastWithDefaults); + return useToastStore().addToast(toastWithDefaults); }; diff --git a/src/hooks/useToast.wrapper.ts b/src/hooks/useToast.wrapper.ts index 10b1195..a34b283 100644 --- a/src/hooks/useToast.wrapper.ts +++ b/src/hooks/useToast.wrapper.ts @@ -1,5 +1,5 @@ -import { useToast as useOriginalToast, toast as originalToast } from '@/hooks/use-toast'; +import { useToast as useOriginalToast, toast as originalToast, ToasterToast } from '@/hooks/use-toast'; // 토스트 중복 호출 방지를 위한 디바운스 구현 let lastToastTime = 0; @@ -7,7 +7,7 @@ let lastToastMessage = ''; const DEBOUNCE_TIME = 500; // 0.5초 내에 동일 메시지 방지 // 중복 토스트 방지 래퍼 함수 -const debouncedToast = (params: Parameters[0]) => { +const debouncedToast = (params: Omit) => { const now = Date.now(); const currentMessage = params.description?.toString() || ''; @@ -26,5 +26,12 @@ const debouncedToast = (params: Parameters[0]) => { }); }; -export const useToast = useOriginalToast; -export const toast = debouncedToast as typeof originalToast; +export const useToast = () => { + const toast = useOriginalToast(); + return { + ...toast, + toast: debouncedToast, + }; +}; + +export const toast = debouncedToast; diff --git a/src/utils/auth/toastUtils.ts b/src/utils/auth/toastUtils.ts index 1a808dd..d09f877 100644 --- a/src/utils/auth/toastUtils.ts +++ b/src/utils/auth/toastUtils.ts @@ -9,5 +9,9 @@ export const showAuthToast = ( description: string, variant: 'default' | 'destructive' = 'default' ) => { - toast({ title, description, variant }); + toast({ + title, + description, + ...(variant === 'destructive' ? { variant: 'destructive' } : {}) + }); };