65 lines
1.1 KiB
TypeScript
65 lines
1.1 KiB
TypeScript
import { toast } from "sonner";
|
|
|
|
/**
|
|
* Muestra un toast de aviso
|
|
*/
|
|
export function showInfoToast(title: string, description?: string, id?: number | string) {
|
|
toast.info(title, {
|
|
description,
|
|
id,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Muestra un toast de aviso
|
|
*/
|
|
export function showWarningToast(title: string, description?: string, id?: number | string) {
|
|
toast.warning(title, {
|
|
description,
|
|
id,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Muestra un toast de éxito
|
|
*/
|
|
export function showSuccessToast(title: string, description?: string, id?: number | string) {
|
|
toast.success(title, {
|
|
description,
|
|
id,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Muestra un toast de error
|
|
*/
|
|
export function showErrorToast(title: string, description?: string, id?: number | string) {
|
|
toast.error(title, {
|
|
description,
|
|
id,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Toast con opción "Undo" (deshacer)
|
|
* @param message
|
|
* @param onUndo
|
|
* @returns
|
|
*/
|
|
|
|
export function showUndoToast(
|
|
message: string,
|
|
onUndo: () => void,
|
|
id?: number | string
|
|
): number | string {
|
|
return toast(message, {
|
|
id,
|
|
description: "",
|
|
action: {
|
|
label: "Undo",
|
|
onClick: onUndo,
|
|
},
|
|
duration: 5000,
|
|
});
|
|
}
|