import {
  GroupDescriptor,
  SortDescriptor,
  State,
} from "@progress/kendo-data-query";
import { BaseProps } from "../../DomainProps";
import { HeaderActionBarType } from "./GridWidgetView";

export interface GridDataState {
  records: any[];
  total: number;
}

export interface GridState extends State {}

export interface GridProps extends BaseProps {
  dataItemKey?: string;
  lazyLoading?: boolean;
  sortConfig?: SortConfig;
  filterConfig?: FilterConfig;
  groupConfig?: GroupConfig;
  paginationConfig?: PaginationConfig;
  expandField?: string;
  selectedField?: string;
  columns?: any[];
  headerActionBar?: HeaderActionBarType;
  config?: any;
  onScreenDataLoad?: (callBack: (response: any) => void) => void;
  navigate?: (callBack: null, id: number | string) => void;
  onModelUpdate?: (
    callBack: ((args: any) => void) | null,
    fieldName: string,
    value: any
  ) => void;
}

type PaginationProps = {
  buttonCount?: number;
  info?: boolean;
  pageSizes?: Array<number>;
  previousNext?: boolean;
  paginationType?: "numeric" | "input";
};

type SortConfig = {
  sortable?: boolean;
  sortMode?: string;
  defaultSortFields: Array<SortDescriptor>;
};

type FilterConfig = {
  filterable?: boolean;
  defaultFilterCriteria: { pattern: string; filters: any[] };
};

type GroupConfig = {
  groupable?: boolean;
  defaultGroupFields: Array<GroupDescriptor>;
};

type PaginationConfig = {
  pageable?: boolean;
  paginationInfo?: PaginationProps;
  defaultPagination: { skip: number; take: number };
};

export enum CellType {
  ACTIONCELL = "ACTIONCELL",
}
