/*
 * @Author: zhoux zhouxia@supervision.ltd
 * @Date: 2023-12-27 10:30:10
 * @LastEditors: zhoux zhouxia@supervision.ltd
 * @LastEditTime: 2023-12-27 11:06:00
 * @FilePath: \general-ai-platform-web\src\components\TableActionCard\isModalDelete.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 '@umijs/max';
import modal from 'antd/es/modal';

type IsModalDeleteProps = {
  deleteButton: React.ReactNode;
  deleteApi: () => void;
  titleText?: string;
  contentText?: string;
};

const IsModalDelete: React.FC<IsModalDeleteProps> = (props) => {
  const intl = useIntl();
  const confirm = () => {
    modal.confirm({
      title: props.titleText || `确认删除吗？`,
      icon: <ExclamationCircleOutlined />,
      content: props.contentText || '确认删除吗？删除后将无法找回，请谨慎操作。',
      okText: intl.formatMessage({ id: 'common.okText', defaultMessage: '$$$' }),
      cancelText: intl.formatMessage({ id: 'common.cancelText', defaultMessage: '$$$' }),
      onOk() {
        props.deleteApi();
      },
      onCancel() {
        console.log('Cancel');
      },
    });
  };

  return (
    <>
      <span onClick={() => confirm()}>{props.deleteButton}</span>
    </>
  );
};

export default IsModalDelete;
