import { MyButtons } from '@/common';
import { Modal } from 'antd';
import { useState } from 'react';

export function MyModal(props?: any) {
  const [open, setOpen] = useState(false);
  return (
    <>
      <MyButtons.View
        title={props.title || '详情'}
        onClick={() => setOpen(true)}
      />
      <Modal
        title={props?.modal?.title || '标题'}
        open={open}
        onOk={() => {
          setOpen(false);
          props?.handleOk?.();
        }}
        onCancel={() => {
          setOpen(false);
          props?.onCancel?.();
        }}
        footer={props?.modal?.footer || false}
        {...props}
      >
        {props?.node}
      </Modal>
    </>
  );
}
