From d783c26e322828975a4cfe55d78e517465efac40 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Sat, 19 Oct 2024 15:52:28 +0200 Subject: [PATCH] chore: Extract to constants --- crates/web/frontend/src/lib/constants.ts | 6 ++++++ crates/web/frontend/src/lib/notify.ts | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/web/frontend/src/lib/constants.ts b/crates/web/frontend/src/lib/constants.ts index 54c4546..8e5441e 100644 --- a/crates/web/frontend/src/lib/constants.ts +++ b/crates/web/frontend/src/lib/constants.ts @@ -1 +1,7 @@ +// Sharing export const MAX_SHARE_SIZE = 2000000; // 2MB + +// Notifications +export const INFO_DURATION = 2000; +export const SUCCESS_DURATION = 2000; +export const ERROR_DURATION = 5000; diff --git a/crates/web/frontend/src/lib/notify.ts b/crates/web/frontend/src/lib/notify.ts index 38441c9..22d2bd8 100644 --- a/crates/web/frontend/src/lib/notify.ts +++ b/crates/web/frontend/src/lib/notify.ts @@ -1,19 +1,20 @@ import { type ExternalToast, toast } from "sonner"; +import { ERROR_DURATION, INFO_DURATION, SUCCESS_DURATION } from "./constants"; const loading = (message: string | React.ReactNode, data?: ExternalToast): string | number => { return toast.loading(message, data); }; const success = (message: string | React.ReactNode, data?: ExternalToast): string | number => { - return toast.success(message, { ...data, duration: 2000 }); + return toast.success(message, { ...data, duration: SUCCESS_DURATION }); }; const info = (message: string | React.ReactNode, data?: ExternalToast): string | number => { - return toast.info(message, { ...data, duration: 2000 }); + return toast.info(message, { ...data, duration: INFO_DURATION }); }; const error = (message: string | React.ReactNode, data?: ExternalToast): string | number => { - return toast.error(message, { ...data, duration: 5000 }); + return toast.error(message, { ...data, duration: ERROR_DURATION }); }; export const notify = {