import { toast } from 'sonner';
import { createElement } from 'react';
import { IconNotification } from '@/components/application/notifications/notifications';

export const notify = {
    success: (title: string, description?: string) => {
        toast.custom((t) =>
            createElement(IconNotification, {
                title,
                description: description ?? '',
                color: 'success',
                hideDismissLabel: true,
                onClose: () => toast.dismiss(t),
            }),
        );
    },

    error: (title: string, description?: string) => {
        toast.custom((t) =>
            createElement(IconNotification, {
                title,
                description: description ?? '',
                color: 'error',
                hideDismissLabel: true,
                onClose: () => toast.dismiss(t),
            }),
        );
    },

    warning: (title: string, description?: string) => {
        toast.custom((t) =>
            createElement(IconNotification, {
                title,
                description: description ?? '',
                color: 'warning',
                hideDismissLabel: true,
                onClose: () => toast.dismiss(t),
            }),
        );
    },

    info: (title: string, description?: string) => {
        toast.custom((t) =>
            createElement(IconNotification, {
                title,
                description: description ?? '',
                color: 'default',
                hideDismissLabel: true,
                onClose: () => toast.dismiss(t),
            }),
        );
    },
};
