p 1 and 2 compeleted

This commit is contained in:
dimitar committed 2026-03-11 01:43:19 +01:00
1 parent 6adb541967
commit 3573709d99
28 files changed
+2533 -240

No files matched your search

+77
View File
@@ -0,0 +1,77 @@
import { toast as sonnerToast } from "sonner";
/**
* Toast notification utility wrapper around Sonner
*
* Provides a consistent API for showing toast notifications throughout the app
*/
export const toast = {
/**
* Show a success toast notification
* @param message - The message to display
* @param description - Optional description text
*/
success: (message: string, description?: string) => {
return sonnerToast.success(message, { description });
},
/**
* Show an error toast notification
* @param message - The message to display
* @param description - Optional description text
*/
error: (message: string, description?: string) => {
return sonnerToast.error(message, { description });
},
/**
* Show an info toast notification
* @param message - The message to display
* @param description - Optional description text
*/
info: (message: string, description?: string) => {
return sonnerToast.info(message, { description });
},
/**
* Show a warning toast notification
* @param message - The message to display
* @param description - Optional description text
*/
warning: (message: string, description?: string) => {
return sonnerToast.warning(message, { description });
},
/**
* Show a loading toast notification
* @param message - The message to display
* @returns Toast ID that can be used to update or dismiss the toast
*/
loading: (message: string) => {
return sonnerToast.loading(message);
},
/**
* Show a promise toast that updates based on promise state
* @param promise - The promise to track
* @param messages - Messages for loading, success, and error states
*/
promise: <T>(
promise: Promise<T>,
messages: {
loading: string;
success: string | ((data: T) => string);
error: string | ((error: Error) => string);
},
) => {
return sonnerToast.promise(promise, messages);
},
/**
* Dismiss a specific toast by ID or all toasts
* @param toastId - Optional toast ID to dismiss. If not provided, dismisses all toasts
*/
dismiss: (toastId?: string | number) => {
return sonnerToast.dismiss(toastId);
},
};