/*
 * @Author: zhoux zhouxia@supervision.ltd
 * @Date: 2023-11-16 14:30:15
 * @LastEditors: zhoux zhouxia@supervision.ltd
 * @LastEditTime: 2023-11-16 14:35:20
 * @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 { ExclamationCircleOutlined } from '@ant-design/icons';
// import { useIntl } from '@ant-design/pro-components';
import { useIntl } from '@umijs/max';
import { Button, Modal } from 'antd';
import { FormattedMessage } from 'react-intl';

type IsBatchDeleteProps = {
  // eslint-disable-next-line @typescript-eslint/ban-types
  deleteApi: Function;
};

const IsBatchDelete: React.FC<IsBatchDeleteProps> = (props) => {
  const intl = useIntl();

  return (
    <Button
      danger
      onClick={async () => {
        Modal.confirm({
          icon: <ExclamationCircleOutlined />,
          title: intl.formatMessage({
            id: 'common.modal.table.delete.title',
            defaultMessage: '$$$',
          }),
          content: intl.formatMessage({
            id: 'common.modal.table.delete.content',
            defaultMessage: '$$$',
          }),
          okText: intl.formatMessage({ id: 'common.yes', defaultMessage: '$$$' }),
          cancelText: intl.formatMessage({ id: 'common.no', defaultMessage: '$$$' }),
          onOk() {
            // TODO 未对接批量删除接口
            props.deleteApi();
          },
          onCancel() {
            console.log('Cancel');
          },
        });
      }}
    >
      <FormattedMessage id="pages.searchTable.batchDeletion" defaultMessage="Batch deletion" />
    </Button>
  );
};

export default IsBatchDelete;
