Skip to content

Commit

Permalink
chore: Extract to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
daavidrgz committed Oct 19, 2024
1 parent 6c8711d commit d783c26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crates/web/frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 4 additions & 3 deletions crates/web/frontend/src/lib/notify.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down

0 comments on commit d783c26

Please sign in to comment.