/*
 * @Author: your name
 * @Date: 2022-01-12 15:26:43
 * @LastEditTime: 2022-01-20 14:32:16
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /KC-MiddlePlatform/src/components/KCModal/index.tsx
 */

import React, { useState, useEffect } from 'react';
import { ModalForm } from '@ant-design/pro-form';
import { KCModalType } from './typing';

const KCModal: React.FC<KCModalType.KCModalProps> = ({
  visible = false,
  modalProps,
  ...props
}) => {
  const [modalVisible, setModalVisible] = useState(false);

  useEffect(() => {
    setModalVisible(visible);
  }, [visible]);

  return (
    <ModalForm
      visible={modalVisible}
      modalProps={{
        destroyOnClose: true,
        bodyStyle: {
          maxHeight: '72vh',
          overflowY: 'auto',
        },
        ...modalProps,
      }}
      {...props}
    />
  );
};

export default KCModal;
