import { WARNING_TYPE } from "@/types";
import { Modal, ModalProps } from "antd";
import { FC } from "react";

export interface WarningModalProps extends Omit<ModalProps, "onOk"> {
  type: WARNING_TYPE;
  onCancel?: () => void;
  onOk?: () => void;
}

const WARNING = [
  "为确保考核公正，发布后，不可编辑考核信息及指标。",
  "终止考核后，将无法继续填报和评定",
];

export const WarningModal: FC<WarningModalProps> = ({
  type,
  open,
  onOk,
  onCancel,
  ...rest
}) => {
  const handleCancel = () => {
    onCancel?.();
  };

  const handleConfirm = () => {
    onOk?.();
  };

  return (
    <Modal
      title="提示"
      okText="确定"
      cancelText="取消"
      maskClosable={false}
      open={open}
      width={400}
      onOk={handleConfirm}
      onCancel={handleCancel}
      {...rest}
    >
      <p>{WARNING[type]}</p>
    </Modal>
  );
};
