mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 20:38:17 +00:00
Merge freight/develop into feature/trains-management
This commit is contained in:
24
apps/edr-freight-web/backoffice/src/hooks/use-toast.ts
Normal file
24
apps/edr-freight-web/backoffice/src/hooks/use-toast.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user