From 49b4c6fbd3e06f6ae87cf0072451d285108b2113 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Wed, 2 Oct 2024 10:39:31 +0200 Subject: [PATCH] provide duration for toast --- src/utils/showToast.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/showToast.tsx b/src/utils/showToast.tsx index c7ea4329..19cf088e 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 }, + ); }; -- GitLab