import { Course } from './course';

export interface Resultat {
  id: string;
  course: Course;
  /**
   * Ordre d'arrivée des chevaux.
   * The backend returns an array of strings/numbers (cheval numbers);
   * in the UI we normalize them to plain numbers.
   */
  ordreArrivee: number[];
  /**
   * Chevaux en dead-heat (ex aequo), represented by their numbers.
   */
  chevauxDeadHeat: number[];
  totalMises: number;
  masseAPartager: number;
  prelevementsLegaux: number;
  montantRembourse: number;
  montantCagnotte: number;
  adeadHeat: boolean;
  createdAt?: string;
  updatedAt?: string;
}

// API response structure (course may be just an ID in some cases)
export interface ResultatApiResponse {
  id: string | number;
  course: Course | string | number;
  /**
   * In the raw API this is an array of strings/numbers.
   */
  ordreArrivee: (string | number)[];
  chevauxDeadHeat: (string | number)[];
  totalMises: number;
  masseAPartager: number;
  prelevementsLegaux: number;
  montantRembourse: number;
  montantCagnotte: number;
  adeadHeat: boolean;
  createdAt?: string;
  updatedAt?: string;
}

// POST payload structure
export interface CreateResultatPayload {
  course: {
    id: string | number;
  };
  ordreArrivee: string[];
  chevauxDeadHeat?: (string | number)[];
  totalMises?: number;
  masseAPartager?: number;
  prelevementsLegaux?: number;
  montantRembourse?: number;
  montantCagnotte?: number;
  adeadHeat?: boolean;
}
