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


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

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

