18 lines
468 B
TypeScript
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 };
|
|
}
|