import { type ExternalToast, toast as sonnerToast } from 'sonner'
import { Toast } from './Toast'

export const toast = {
  success: (message: React.ReactNode, options?: ExternalToast) =>
    sonnerToast.custom(
      (t) => (
        <Toast
          variant="success"
          message={message}
          onClose={() => sonnerToast.dismiss(t)}
        />
      ),
      options
    ),
  info: (message: React.ReactNode, options?: ExternalToast) =>
    sonnerToast.custom(
      (t) => (
        <Toast
          variant="info"
          message={message}
          onClose={() => sonnerToast.dismiss(t)}
        />
      ),
      options
    ),
  error: (message: React.ReactNode, options?: ExternalToast) =>
    sonnerToast.custom(
      (t) => (
        <Toast
          variant="error"
          message={message}
          onClose={() => sonnerToast.dismiss(t)}
        />
      ),
      options
    ),
  warning: (message: React.ReactNode, options?: ExternalToast) =>
    sonnerToast.custom(
      (t) => (
        <Toast
          variant="warning"
          message={message}
          onClose={() => sonnerToast.dismiss(t)}
        />
      ),
      options
    ),
}
