/*
 * @Author: zhoux zhouxia@supervision.ltd
 * @Date: 2023-11-16 14:30:15
 * @LastEditors: zhoux zhouxia@supervision.ltd
 * @LastEditTime: 2023-11-16 16:22:15
 * @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 { useIntl } from '@umijs/max';
import { Button, Popconfirm } from 'antd';
import { FormattedMessage } from 'react-intl';

type isConfirmActionProps = {
  // eslint-disable-next-line @typescript-eslint/ban-types
  confirmAction: Function;
  title: string;
  description?: string;
  buttonText?: string;
  buttonFormatText?: string;
};

const IsConfirmAction: React.FC<isConfirmActionProps> = (props) => {
  const intl = useIntl();
  const description = props.description || `确认${props.title}吗?`;
  return (
    <Popconfirm
      title={props.title}
      description={description}
      onConfirm={() => {
        props.confirmAction();
      }}
      onCancel={() => {}}
      okText={intl.formatMessage({ id: 'common.yes', defaultMessage: '$$$' })}
      cancelText={intl.formatMessage({ id: 'common.no', defaultMessage: '$$$' })}
    >
      <Button
        type="link"
        size="small"
        onClick={() => {
          // setPublishModalOpen(true);
        }}
      >
        {/* 自定义文案优先 */}
        {props.buttonText ? (
          props.buttonText
        ) : (
          <FormattedMessage id={props.buttonFormatText} defaultMessage="$$$" />
        )}
      </Button>
    </Popconfirm>
  );
};

export default IsConfirmAction;
