import type { Client, PaginatedResponse } from './client';

export type FunnelStage =
  | 'NEW'
  | 'ASSIGNED'
  | 'APPOINTMENT_SET'
  | 'COMPLETED'
  | 'REGULAR'
  | 'TRANSFERRED'
  | 'REFUSED';

export interface FunnelEntry {
  id: string;
  clientId: string;
  client: Client;
  stage: FunnelStage;
  trainerId?: string;
  trainer?: { id: string; firstName: string; lastName: string } | null;
  trainerFirstName?: string;
  trainerLastName?: string;
  departmentId?: string;
  departmentName?: string;
  comment?: string;
  createdAt: string;
  updatedAt: string;
}

export interface FunnelHistoryItem {
  id: string;
  fromStage: FunnelStage | null;
  toStage: FunnelStage;
  comment?: string;
  performedBy: string;
  performedByName: string;
  createdAt: string;
}

export interface FunnelClientDetail {
  entry: FunnelEntry;
  history: FunnelHistoryItem[];
}

export interface AssignClientDto {
  clientId: string;
  trainerId: string;
  comment?: string;
}

export interface MoveStageDto {
  toStage: FunnelStage;
  comment?: string;
}

export interface TransferClientDto {
  trainerId: string;
  departmentId?: string;
  comment?: string;
}

export interface RefuseClientDto {
  reason: string;
  comment: string;
}

export interface FunnelConversionStats {
  totalNew: number;
  totalAssigned: number;
  totalCompleted: number;
  totalRegular: number;
  totalRefused: number;
  newToAssigned: number;
  assignedToCompleted: number;
  completedToRegular: number;
}

export interface FunnelDistribution {
  trainerId: string;
  trainerFirstName: string;
  trainerLastName: string;
  newCount: number;
  assignedCount: number;
  completedCount: number;
  regularCount: number;
}

export interface FunnelEntriesParams {
  stage?: FunnelStage;
  trainerId?: string;
  cursor?: string;
  limit?: number;
}

export type PaginatedFunnelEntries = PaginatedResponse<FunnelEntry>;

export interface TrainerOption {
  id: string;
  firstName: string;
  lastName: string;
  departmentName?: string;
}
