import { ApiProperty } from '@nestjs/swagger';
import { IsBoolean, IsEnum, IsString } from 'class-validator';
import {
  PENALTY_TYPE_VALUES,
  type PenaltyTypeValue,
} from '@core/racing/domain/entities/penalty/PenaltyType';

export type PenaltyValueKindDTO = 'seconds' | 'grid_positions' | 'points' | 'races' | 'none';

export class PenaltyTypeReferenceDTO {
  @ApiProperty({ enum: PENALTY_TYPE_VALUES })
  @IsEnum(PENALTY_TYPE_VALUES)
  type!: PenaltyTypeValue;

  @ApiProperty()
  @IsBoolean()
  requiresValue!: boolean;

  @ApiProperty({ enum: ['seconds', 'grid_positions', 'points', 'races', 'none'] })
  @IsString()
  valueKind!: PenaltyValueKindDTO;
}

export class PenaltyDefaultReasonsDTO {
  @ApiProperty()
  @IsString()
  upheld!: string;

  @ApiProperty()
  @IsString()
  dismissed!: string;
}

export class PenaltyTypesReferenceDTO {
  @ApiProperty({ type: [PenaltyTypeReferenceDTO] })
  penaltyTypes!: PenaltyTypeReferenceDTO[];

  @ApiProperty({ type: PenaltyDefaultReasonsDTO })
  defaultReasons!: PenaltyDefaultReasonsDTO;
}