import React from 'react';
import { Modal } from 'antd';
import { ModalFuncProps } from 'antd/es/modal';
import IconFont from '@sensoro/library/lib/components/icon-font';

const { confirm: confirmM } = Modal;
export const showDeleteConfirm = ({
  title,
  content,
  ...rest
}: ModalFuncProps) => {
  confirmM({
    title,
    content,
    okText: '确认',
    cancelText: '取消',
    icon: <IconFont type="icon-attention" style={{ color: '#E57022' }} />,
    ...rest,
  });
};

export const confirm = (
  { title, content, ...rest }: ModalFuncProps,
  type?: 'warning' = 'warning',
) => {
  const typeMapIcon = {
    warning: <IconFont type="icon-attention" style={{ color: '#E57022' }} />,
  };
  confirmM({
    title,
    content,
    okText: '确认',
    cancelText: '取消',
    icon: typeMapIcon[type] || (
      <IconFont type="icon-attention" style={{ color: '#E57022' }} />
    ),
    ...rest,
  });
};
