import React from "react";

export type ITabPaneProps = {
  value?: string | number;
  title?: string | number;
};

export type Record<T> = {
  data?: T[];
  success?: boolean;
  hasMore?: boolean;
};

export type Query = {
  pageIndex?: number;
  pageSize?: number;
};

export type TabPane = {
  value: string | number;
  title: string | number;
};

export type ToolBar<T> = {
  selectRow?: {
    onClick: (selectRow: any[]) => void;
  };
  actions?: React.ReactNode[];
  tabs?: {
    activeKey: string;
    defaultActiveKey: string | number;
    items: TabPane[];
    onChange: (index: string | number) => void;
  };
  search?: {
    activeKey: string;
    defaultActiveKey: string;
    items: any[];
  };
  render?: () => React.ReactNode | undefined;
  footer?: (record: T[]) => React.ReactNode | undefined;
};

export type IRecordListProps<T = {}, Q extends Query = Query> = {
  rowId: string;
  height?: number;
  itemHeight: number;
  type: "virtual" | "infinite";
  skeleton?: React.ReactNode;
  actionRef: React.MutableRefObject<any>;
  toolbar?: ToolBar<T>;
  render: (record: T, index: number) => React.ReactNode;
  request: (params: Q) => Promise<Record<T>>;
  pagination: {
    pageSize?: number;
  };
  tabbar?: React.ReactNode;
  params?: Q;
  px?: boolean;
};

export type ActionType = {
  reload: () => void;
};
