/**
 * Filter Types
 */

// Available filter types
export type FilterType = 'text' | 'enum' | 'date' | 'number' | 'boolean';

// Filter definition for a column
export interface Filter {
  label: string;
  title: string; // Field name to filter by
  type?: FilterType;
  // For enum filters - available options
  options?: string[];
  // Flags for specialized filters
  number?: boolean;
  date?: boolean;
}

// Active filter item (user-created filter)
export interface FilterItem {
  id: string;
  fields: FilterFields;
}

// Filter field values
export interface FilterFields {
  selectedField: string;
  filterValue: string;
  filterValueFrom: string;
  filterValueTo: string;
}

// Filter request format for API
export type FilterRequest = Record<string, string | string[]>;

// Table column configuration
export interface TableColumnConfig {
  field: string;
  headerName: string;
  width?: number;
  minWidth?: number;
  maxWidth?: number;
  flex?: number;
  editable?: boolean;
  sortable?: boolean;
  filterable?: boolean;
  // For enum columns
  type?: 'string' | 'number' | 'date' | 'dateTime' | 'boolean' | 'singleSelect';
  valueOptions?: string[];
  // Custom render function name
  renderType?:
    | 'link'
    | 'boolean'
    | 'date'
    | 'datetime'
    | 'image'
    | 'actions'
    | 'relation';
  // For relation columns
  relationField?: string;
}

// Table configuration for generic table
export interface TableConfig {
  entityName: string;
  columns: TableColumnConfig[];
  filters: Filter[];
  defaultSort?: {
    field: string;
    sort: 'asc' | 'desc';
  };
  perPage?: number;
}
