import InitForm from "../InitForm";
import { Drawer } from "antd";
import React, { useState, memo } from "react";
import Details from "../Details/detail";
// title="Basic Drawer"
// placement="right"
// closable={false}
// onClose={this.onClose}
// visible={this.state.visible}
// getContainer={false}
// style={{ position: 'absolute' }}

// drawer props + initform props + detial props



function DrawInitForm(props) {
  let newProps = { ...props };
  delete newProps.children;

  const detailprops = {
    totalPath: props.totalPath,
    dataSource: props.detaildataSource,
    totalCard: props.totalCard,
    totalParams: props.totalParams,
    col: props.col,
    bottomNode: props.bottomNode,
    topNode: props.topNode,
    printRef: props.printRef,
    onloadeddata: props.onloadeddata,
    expandkeys: props.expandkeys,
    reload:props.reload
  }
  return (
    <Drawer
      maskClosable={false}
      placement="right"
      closable={true}
      getContainer={false}
      style={{ position: "absolute", transform: "translateX(0)",maxWidth:"100%" }}
      width={props.val == "detail" ? 1000 : props.width}
      destroyOnClose={true}
      {...props}
    >
      {props.val == "only" && props.children}
      {props.val == "only" ? null : props.val == "detail" ? <Details {...detailprops}></Details> : <InitForm {...newProps}></InitForm>}
    </Drawer>
  );
}

export default DrawInitForm;