import { type User } from 'src/types/user';

import { type AgentGroup } from './agent';
import { type SmSortDirection, type SmSortField } from './common';
import { type ServiceItem } from './serviceItem';
import { type State } from './state';

export type CoordinatorFilterParams = {
  page?: number;
  limit?: number;
  text?: string;
  helpDeskId: string;
  catalogItemsIn?: string;
  statesIn?: string;
  createdAtFrom?: string;
  createdAtTo?: string;
  initiatorsIn?: string;
  assigneesIn?: string;
  agentGroupsIn?: string;
  initiatorSegmentations?: string;
  sortDirection?: SmSortDirection;
  sortField?: SmSortField;
};

export type CollaboratorPanelFilters = {
  serviceItemsIn?: ServiceItem[];
  agentsIn?: User[];
  agentGroupsIn?: AgentGroup[];
  creationDateFrom?: Date | null;
  creationDateTo?: Date | null;
  dateOptions?: Record<string, boolean>;
};

export type CoordinatorTaskFilters = CollaboratorPanelFilters & {
  statesIn?: State[];
  initiatorsIn?: User[];
  collaboratorTypesIn?: { title: string; id: number }[];
};

export type ParsedTaskAgentPanelFilters = Pick<
  CoordinatorTaskFilters,
  | 'serviceItemsIn'
  | 'agentsIn'
  | 'agentGroupsIn'
  | 'statesIn'
  | 'initiatorsIn'
  | 'collaboratorTypesIn'
> & {
  startDate: Date | null;
  endDate: Date | null;
};

export type ServiceMetrics = {
  totalTasks: number;
  tasksByStatus: Record<string, number>; // key: status, value: number of tasks
  avgAssignmentTimeSeconds: number;
  avgResolutionTimeSeconds: number;
  avgCsatRating: number;
};

export type OxxoCollaboratorType = {
  id: number;
  title: string;
};
