import React from "react";
import {Drawer} from "antd";
import {ProColumns, ProDescriptions, ProDescriptionsItemProps} from "@ant-design/pro-components";

export type ColumnDrawProps = {
  handleDrawer: ()=>void;
  isShowDetail: boolean;
  columns: ProColumns<API.Menu>[];
  currentRow: API.Menu | undefined;
  setCurrentRow: (value: any)=>void;
};


const ColumnDrawer: React.FC<ColumnDrawProps> = (props) => {

  return (
    <Drawer
      width={600}
      open={props.isShowDetail}
      onClose={() => {
        props.setCurrentRow(undefined);
        props.handleDrawer();
      }}
      closable={false}
    >
      {props.currentRow?.name && (
        <ProDescriptions<API.Menu>
          column={2}
          title={props.currentRow?.name}
          request={async () => ({
            data: props.currentRow || {},
          })}
          params={{
            id: props.currentRow?.name,
          }}
          columns={props.columns as ProDescriptionsItemProps<API.Menu>[]}
        />
      )}
    </Drawer>
  )
}
export default ColumnDrawer

