Files
KLC-Hr-Dashboard-Frontend/src/components/toast/useToast.ts
2026-04-10 16:38:25 +05:30

18 lines
468 B
TypeScript

import { toast } from 'sonner';
export type ToastVariant = 'success' | 'error' | 'info';
export function useToast() {
const showToast = (title: string, description: string, variant: ToastVariant = 'info') => {
if (variant === 'success') {
toast.success(title, { description });
} else if (variant === 'error') {
toast.error(title, { description });
} else {
toast(title, { description });
}
};
return { showToast, toast };
}