diff --git a/src/utils/showToast.tsx b/src/utils/showToast.tsx index c7ea4329137a508aec4b93357e63442ef6c3c795..19cf088efa33e211ecc440c0ca3b5ceb96d4ef61 100644 --- a/src/utils/showToast.tsx +++ b/src/utils/showToast.tsx @@ -1,13 +1,17 @@ import { toast } from 'sonner'; import { Toast } from '@/shared/Toast'; +const DEFAULT_DURATION_MS = 5000; + type ShowToastArgs = { type: 'success' | 'error'; message: string; + duration?: number; }; export const showToast = (args: ShowToastArgs): void => { - toast.custom(t => ( - <Toast message={args.message} onDismiss={() => toast.dismiss(t)} type={args.type} /> - )); + toast.custom( + t => <Toast message={args.message} onDismiss={() => toast.dismiss(t)} type={args.type} />, + { duration: args.duration ? args.duration : DEFAULT_DURATION_MS }, + ); };