import React from 'react';
import { message, notification } from 'antd';
import { CheckCircleOutlined, CloseCircleOutlined, WarningOutlined, InfoOutlined } from '@ant-design/icons';

export const NotificationUtils = {
  success: (content: string, duration: number = 3000) => {
    message.success({
      content,
      duration,
      icon: React.createElement(CheckCircleOutlined),
    });
  },

  error: (content: string, duration: number = 3000) => {
    message.error({
      content,
      duration,
      icon: React.createElement(CloseCircleOutlined),
    });
  },

  warning: (content: string, duration: number = 3000) => {
    message.warning({
      content,
      duration,
      icon: React.createElement(WarningOutlined),
    });
  },

  info: (content: string, duration: number = 3000) => {
    message.info({
      content,
      duration,
      icon: React.createElement(InfoOutlined),
    });
  },

  notify: (
    type: 'success' | 'error' | 'warning' | 'info',
    title: string,
    description: string,
    duration: number = 4500
  ) => {
    notification[type]({
      message: title,
      description,
      duration,
      placement: 'topRight',
    });
  },

  successNotify: (title: string, description: string, duration: number = 4500) => {
    NotificationUtils.notify('success', title, description, duration);
  },

  errorNotify: (title: string, description: string, duration: number = 4500) => {
    NotificationUtils.notify('error', title, description, duration);
  },

  warningNotify: (title: string, description: string, duration: number = 4500) => {
    NotificationUtils.notify('warning', title, description, duration);
  },

  infoNotify: (title: string, description: string, duration: number = 4500) => {
    NotificationUtils.notify('info', title, description, duration);
  },
};

export default NotificationUtils;
