import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsOptional, IsString, ValidateNested } from 'class-validator';

class LeagueRosterJoinRequestDriverDTO {
  @ApiProperty()
  @IsString()
  id!: string;

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

export class LeagueRosterJoinRequestDTO {
  @ApiProperty()
  @IsString()
  id!: string;

  @ApiProperty()
  @IsString()
  leagueId!: string;

  @ApiProperty()
  @IsString()
  driverId!: string;

  @ApiProperty({ format: 'date-time' })
  @IsString()
  requestedAt!: string;

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  message?: string;

  @ApiProperty({ type: () => LeagueRosterJoinRequestDriverDTO })
  @ValidateNested()
  @Type(() => LeagueRosterJoinRequestDriverDTO)
  driver!: LeagueRosterJoinRequestDriverDTO;
}