mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 16:28:12 +00:00
25 lines
611 B
TypeScript
25 lines
611 B
TypeScript
import toast from 'react-hot-toast';
|
|
|
|
interface ToastOptions {
|
|
title?: string;
|
|
description?: string;
|
|
variant?: 'default' | 'destructive';
|
|
duration?: number;
|
|
}
|
|
|
|
export function useToast() {
|
|
const showToast = (options: ToastOptions) => {
|
|
const { title, description, variant = 'default', duration = 3000 } = options;
|
|
|
|
const message = title ? `${title}${description ? ': ' + description : ''}` : description || '';
|
|
|
|
if (variant === 'destructive') {
|
|
toast.error(message, { duration });
|
|
} else {
|
|
toast.success(message, { duration });
|
|
}
|
|
};
|
|
|
|
return { toast: showToast };
|
|
}
|