// dto/create-inspection-report-with-answers.dto.ts
import { Type } from "class-transformer"
import { ArrayMinSize, IsArray, IsInt, ValidateNested } from "class-validator"
import { ApiProperty } from "@nestjs/swagger"

export class InspectionAnswerDto {
  @ApiProperty({ example: 1 })
  @IsInt()
  question_id: number

  @ApiProperty({ example: 2 })
  @IsInt()
  selected_answer_id: number
}

export class CreateInspectionReportWithAnswersDto {
  @ApiProperty({ example: 101 })
  @IsInt()
  fleet_id: number

  @ApiProperty({ example: 218 })
  @IsInt()
  driver_id: number

  @ApiProperty({
    type: [InspectionAnswerDto],
    example: [
      { question_id: 1, selected_answer_id: 2 },
      { question_id: 2, selected_answer_id: 3 },
    ],
  })
  @IsArray()
  @ArrayMinSize(1)
  @ValidateNested({ each: true })
  @Type(() => InspectionAnswerDto)
  answers: InspectionAnswerDto[]
}
