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

export type TrainingStatus =
  | 'PLANNED'
  | 'CONFIRMED'
  | 'COMPLETED'
  | 'CANCELLED'
  | 'NO_SHOW';

export type CancelReason =
  | 'CLIENT_CANCEL'
  | 'NO_CHARGE'
  | 'SALE_RETURN'
  | 'ILLNESS';

export interface Training {
  id: string;
  clientId: string;
  trainerId: string;
  serviceId: string;
  roomId?: string;
  date: string;
  startTime: string;
  endTime: string;
  duration: number;
  status: TrainingStatus;
  cancelReason?: CancelReason;
  cancelComment?: string;
  client?: Client;
  trainer?: TrainerSummary;
  service?: ServiceSummary;
  room?: RoomSummary;
  createdAt: string;
  updatedAt: string;
}

export interface TrainerSummary {
  id: string;
  firstName: string;
  lastName: string;
  avatarUrl?: string;
}

export interface ServiceSummary {
  id: string;
  name: string;
  duration: number;
  color?: string;
}

export interface RoomSummary {
  id: string;
  name: string;
}

export interface TimeSlot {
  startTime: string;
  endTime: string;
  available: boolean;
}

export interface TrainingSearchParams {
  date?: string;
  trainerId?: string;
  clientId?: string;
  status?: TrainingStatus;
  cursor?: string;
  limit?: number;
}

export interface CreateTrainingDto {
  clientId: string;
  serviceId: string;
  date: string;
  startTime: string;
  duration: number;
  roomId?: string;
  repeat?: boolean;
  repeatWeeks?: number;
}

export interface UpdateTrainingDto {
  serviceId?: string;
  date?: string;
  startTime?: string;
  duration?: number;
  roomId?: string;
}

export interface CancelTrainingDto {
  reason: CancelReason;
  comment?: string;
}

export interface RescheduleTrainingDto {
  date: string;
  startTime: string;
}

export interface TrainingsByDateResponse {
  data: Training[];
  date: string;
}

export const CANCEL_REASON_LABELS: Record<CancelReason, string> = {
  CLIENT_CANCEL: 'Отмена клиента',
  NO_CHARGE: 'Без списания',
  SALE_RETURN: 'Возврат продажи',
  ILLNESS: 'Заболел',
};

export const STATUS_LABELS: Record<TrainingStatus, string> = {
  PLANNED: 'Запланировано',
  CONFIRMED: 'Подтверждено',
  COMPLETED: 'Завершено',
  CANCELLED: 'Отменено',
  NO_SHOW: 'Не прибыл',
};
