'use client';

import { toast as sonnerToast } from 'sonner';

export type ToastVariant = 'default' | 'destructive' | 'success' | 'info' | 'warning' | 'error';

interface ToastProps {
    title?: string | React.ReactNode;
    description?: string | React.ReactNode;
    variant?: ToastVariant;
}

export const toast = ({ variant = 'default', ...props }: ToastProps) => {
    switch (variant) {
        case 'success':
            return sonnerToast.success(props.title, { description: props.description });
        case 'destructive':
            return sonnerToast.error(props.title, { description: props.description });
        case 'info':
            return sonnerToast.info(props.title, { description: props.description });
        case 'warning':
            return sonnerToast.warning(props.title, { description: props.description });
        case 'error':
            return sonnerToast.error(props.title, { description: props.description });
        default:
            return sonnerToast(props.title, { description: props.description });
    }
};

export const useToast = () => {
    return {
        toast,
        dismiss: (id?: string | number) => sonnerToast.dismiss(id),
    };
};