import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
import { Transform, Type } from 'class-transformer';

export class GetAttendanceListDto {
  @ApiPropertyOptional({ description: 'Filter by session ID' })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  sessionId?: number;

  @ApiPropertyOptional({ description: 'Filter by program ID' })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  programId?: number;

  @ApiPropertyOptional({ description: 'Filter attended only' })
  @IsOptional()
  @IsBoolean()
  @Transform(({ value }) => value === undefined || value === null ? undefined : value === 'true' || value === true)
  isAttended?: boolean;

  @ApiPropertyOptional({ description: 'Filter by the admin user who checked in the attendee' })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  checkedInByUserId?: number;

  @ApiPropertyOptional({ description: 'Search by name, email or seq number' })
  @IsOptional()
  @IsString()
  search?: string;

  @ApiPropertyOptional({ default: 20 })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  limit?: number = 20;

  @ApiPropertyOptional({ default: 0 })
  @IsOptional()
  @IsInt()
  @Type(() => Number)
  offset?: number = 0;

  @ApiPropertyOptional({ description: 'Set true to download attendance data as Excel file (returns S3 URL)' })
  @IsOptional()
  @IsBoolean()
  @Transform(({ value }) => value === 'true' || value === true)
  isDownload?: boolean;
}
