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

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


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

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

