import { ReactNode } from 'react'

export interface ColumnProps {
  dataIndex: string
  key: string
  title: any
  render?: (cellData: any, row: any, index: number) => any
  textColor?: string
  sort?: boolean
  width?: string //pixels
}

export interface TableProps {
  tableKey?: string
  showSerialNumber?: boolean
  columns: Array<ColumnProps>
  rowKey?: string
  dataSource?: any[]
  loading?: boolean
  refetching?: boolean
  onRowClick?: (row: any) => void
  pagination?: {
    page?: number
    limit: number
    totalCount: number
    onChange: (offset: number) => void
    onChangeLimit?: (v: number) => void
    handlePageInput?: boolean
  }
  select?: {
    enable: boolean
    onSelection?: (ids: any[], original?: any[]) => void | null
    actions?: {
      component?: (
        ids: any[],
        clearSelection?: () => void,
        originalRows?: any[],
      ) => any
    }[]
  }
  handleCheck?: (value: any) => void
  onSort?: (sort: any) => void
  dense?: boolean
}

export type Order = 'asc' | 'desc' | ''
export type Sort = any

export type TableRowSelectAction = {
  label?: ReactNode
  icon?: ReactNode
  onClick?: (
    ids: any[],
    clearSelection: () => void,
    originalRows?: any[],
  ) => void
  dropdown?: boolean
  component?: any
}
