Fix TypeScript errors

Addresses TypeScript errors related to toast implementation and type definitions.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 09:15:27 +00:00
parent 7ab79d125e
commit 7b50054da4
6 changed files with 23 additions and 17 deletions

View File

@@ -83,7 +83,6 @@ const ExpenseForm: React.FC<ExpenseFormProps> = ({ onSubmit, onCancel, isSubmitt
<ExpenseCategorySelector
value={field.value}
onValueChange={(value) => field.onChange(value)}
disabled={isSubmitting}
/>
</FormItem>
)}

View File

@@ -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';

View File

@@ -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 };

View File

@@ -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<ToasterToast, "id">) => {
// 기본 지속 시간을 적용
const toastWithDefaults = {
...props,
duration: props.duration || DEFAULT_TOAST_DURATION,
};
return toastStore.getState().addToast(toastWithDefaults);
return useToastStore().addToast(toastWithDefaults);
};

View File

@@ -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<typeof originalToast>[0]) => {
const debouncedToast = (params: Omit<ToasterToast, "id">) => {
const now = Date.now();
const currentMessage = params.description?.toString() || '';
@@ -26,5 +26,12 @@ const debouncedToast = (params: Parameters<typeof originalToast>[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;

View File

@@ -9,5 +9,9 @@ export const showAuthToast = (
description: string,
variant: 'default' | 'destructive' = 'default'
) => {
toast({ title, description, variant });
toast({
title,
description,
...(variant === 'destructive' ? { variant: 'destructive' } : {})
});
};