import { Column, CreateDateColumn, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { Dossier } from "./dossiers.entity";

export enum StatutContratType {
  BROUILLON = 'brouillon',
  EN_ATTENTE_SIGNATURE = 'en_attente_signature',
  VALIDE = 'valide',
  RESILIE = 'resilie',
}

@Entity('contrats')
export class Contrat {
  // Define your columns and relationships here

  @PrimaryGeneratedColumn('uuid')
  id: string;

  @OneToOne(() => Dossier, {onDelete: 'CASCADE'} )
  @JoinColumn({ name: 'id_dossier'})
  dossier: Dossier;

  @Column({type: 'jsonb', nullable: true, name: 'planning'})
  planning?: any;

  @Column({type: 'numeric', precision: 6, scale: 2, nullable: true, name: 'tarif_horaire'})
  hourly_rate?: string;

  @Column({type: 'numeric', precision: 6, scale: 2, nullable: true, name: 'indemnites_repas'})
  meal_indemnity?: string;

  @Column( { name: 'date_debut', type: 'date', nullable: true })
  start_date?: Date;

  @Column({
    type: 'enum',
    enum: StatutContratType,
    enumName: 'statut_contrat_type',
    default: StatutContratType.BROUILLON,
    name: 'statut'
  })
  statut: StatutContratType;

  @Column({type: 'boolean', default: false, name: 'signe_parent'})
  signed_by_parent: boolean;

  @Column({type: 'boolean', default: false, name: 'signe_am'})
  signed_by_am: boolean;

  @Column({type: 'timestamptz', nullable: true, name: 'finalise_le'})
  finalized_at?: Date;

  @CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
  created_at: Date;

  @UpdateDateColumn({ name: 'modifie_le', type: 'timestamptz' })
  updated_at: Date;
}
