import { SelectChangeEvent } from '@mui/material';
import { Dispatch, FormEvent, SetStateAction } from 'react';

/* ------------------------------- pagination ------------------------------- */
export type PaginationTableProps = {
  current_page: number;
  from: number;
  last_page: number;
  links: [];
  path: string;
  per_page: number;
  to: number;
  total: number;
};
/* -------------------------------------------------------------------------- */

/* ---------------------------------- order --------------------------------- */
export type Order = 'asc' | 'desc';
/* -------------------------------------------------------------------------- */

/* --------------------------------- filter --------------------------------- */
export type DivisionDataProps = {
  id: number;
  name: string;
};

export type StatusDataProps = {
  id: number;
  name: string;
};
/* -------------------------------------------------------------------------- */

/* -------------------------------- headcell -------------------------------- */
export type HeadCell<DataType> = {
  id: Extract<keyof DataType, string>;
  align: string;
  label: string;
  isSort: boolean;
  width?: number;
};
/* -------------------------------------------------------------------------- */

/* ----------------------------- division filter ---------------------------- */
export type DivisionData = {
  id: number;
  name: string;
};
/* -------------------------------------------------------------------------- */

/* ----------------------------- status filter ---------------------------- */
export type Status = {
  id: number;
  name: string;
};
/* -------------------------------------------------------------------------- */

/* ----------------------------------- row ---------------------------------- */
export type TableListProps<DataType> = {
  headCells?: HeadCell<DataType>[];
  rows?: Array<DataType>;
  paginations?: {
    page: number;
    setPage: Dispatch<SetStateAction<number>>;
    rowsPerPage: number;
    setRowsPerPage: Dispatch<SetStateAction<number>>;
    paginationTable: PaginationTableProps;
    setPaginationTable: Dispatch<SetStateAction<PaginationTableProps>>;
  };
  orders?: {
    order: Order;
    setOrder: Dispatch<SetStateAction<Order>>;
    orderBy: string;
    setOrderBy: Dispatch<SetStateAction<string>>;
  };
  loadings: {
    isLoading: boolean;
    setIsLoading: Dispatch<SetStateAction<boolean>>;
  };
  params?: {
    searchParams: URLSearchParams;
    setSearchParams: any;
    appliedParams: {};
    setAppliedParams: Dispatch<SetStateAction<{}>>;
  };
  searchs?: {
    useSearchs: boolean;
    fullWidth?: boolean;
    searchText: string;
    setSearchText: Dispatch<SetStateAction<string>>;
    handleSearchSubmit: (event: FormEvent<HTMLFormElement>) => void;
  };
  filters?: {
    useFilter: boolean;
    config: {
      label: string;
      divisionValue: string;
      divisionData: DivisionData[];
      handleDivisionChange: (event: SelectChangeEvent) => void;
    };
  };
  filterStatus?: {
    useFilter: boolean;
    config: {
      label: string;
      statusValue: string;
      statusData: Status[];
      handleStatusChange: (event: SelectChangeEvent) => void;
    };
  };
  filterStartDate?: {
    useFilter: boolean;
    startDate: string;
    setStartDate: Dispatch<SetStateAction<string>>;
    handleStartDateChange: (event: FormEvent<HTMLFormElement>) => void;
  };
  filterEndDate?: {
    useFilter: boolean;
    endDate: string;
    setEndDate: Dispatch<SetStateAction<string>>;
    handleEndDateChange: (event: FormEvent<HTMLFormElement>) => void;
  };
  exportReport?: {
    useExport: boolean;
    startDate: string;
    endDate: string;
    status: string;
    handleExportReport: (event: FormEvent<HTMLFormElement>) => void;
  };
  exportLoading?: boolean;
};
/* -------------------------------------------------------------------------- */
