/*
 * @Author: zhoux zhouxia@supervision.ltd
 * @Date: 2023-11-16 14:30:15
 * @LastEditors: zhoux zhouxia@supervision.ltd
 * @LastEditTime: 2023-12-22 16:17:17
 * @FilePath: \general-ai-platform-web\src\components\BatchOperation\isBatchDelete.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// import { useIntl } from '@ant-design/pro-components';
import { DeleteOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Popconfirm } from 'antd';
import { proIconForTableActionStyle } from '../../../config/defaultIcon';
import { FormattedMessage } from 'react-intl';

type IsDeleteProps = {
  // eslint-disable-next-line @typescript-eslint/ban-types
  buttonType?: 'defalut' | 'deleteIcon';
  deleteApi: () => void;
};

const IsDelete: React.FC<IsDeleteProps> = (props) => {
  const intl = useIntl();

  return (
    <Popconfirm
      key="destroy"
      placement="topLeft"
      title={intl.formatMessage({ id: 'common.tip.title', defaultMessage: '温馨提示' })}
      description={intl.formatMessage({
        id: 'common.modal.table.delete.content',
        defaultMessage: '确定删除吗，删除后将无法找回，请谨慎操作',
      })}
      okText={intl.formatMessage({ id: 'common.yes', defaultMessage: '是' })}
      cancelText={intl.formatMessage({ id: 'common.no', defaultMessage: '否' })}
      onConfirm={() => {
        props.deleteApi();
      }}
    >
      {props.buttonType === 'deleteIcon' ? (
        <>
          <DeleteOutlined style={{
            color: "rgba(232, 13, 13, 1)",
          ...proIconForTableActionStyle
          }} />
        </>
      ) : (
        <Button type="link" size="small" danger icon={<DeleteOutlined style={{
          marginRight: 3
      }}/>}>
          <FormattedMessage id="pages.searchTable.destroy" defaultMessage="删除" />
        </Button>
      )}
    </Popconfirm>
  );
};

export default IsDelete;
