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.DeviceGroup>[];
  currentRow: API.DeviceGroup | undefined;
};


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

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

