import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsNumber, ValidateIf } from 'class-validator';

export class GetReportExportDto {
  @ApiProperty({ type: Number, required: false, default: 1 })
  @Transform((body) => Number(body.value))
  @ValidateIf((body) => body.page)
  @IsNumber()
  page = 1;

  @ApiProperty({ type: Number, required: false, default: 10 })
  @Transform((body) => Number(body.value))
  @ValidateIf((body) => body.limit)
  @IsNumber()
  limit = 10;

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  group_names?: string;

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  unique_names?: string[];

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  statuses?: string;
}

export class GetReportExportProcessingDto {
  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  group_names?: string;

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  unique_names?: string[];
}

export class GetReportExportFileNameDto {
  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  group_names?: string;

  @ApiProperty({ type: ['string'], required: false })
  @Transform((body) => {
    return Array.isArray(body.value) ? body.value : [body.value];
  })
  unique_names?: string[];
}
