import { IsOptional, IsEnum, IsDateString, IsString, IsArray } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { RequestStatus } from '../enums/request-status.enum';
import { RequestType } from '../enums/request-type.enum';

export class RequestFiltersDto {
  @ApiPropertyOptional({
    description: 'Filter by request status',
    enum: RequestStatus,
  })
  @IsOptional()
  @IsEnum(RequestStatus)
  status?: RequestStatus;

  @ApiPropertyOptional({
    description: 'Filter by request type',
    enum: RequestType,
  })
  @IsOptional()
  @IsEnum(RequestType)
  requestType?: RequestType;

  @ApiPropertyOptional({
    description: 'Filter by applicant ID',
    example: '550e8400-e29b-41d4-a716-446655440000',
  })
  @IsOptional()
  @IsString()
  applicantId?: string;

  @ApiPropertyOptional({
    description: 'Filter by request number (partial match)',
    example: 'RL-2024',
  })
  @IsOptional()
  @IsString()
  requestNumber?: string;

  @ApiPropertyOptional({
    description: 'Filter by department code',
    example: 'FIRE_SAFETY',
  })
  @IsOptional()
  @IsString()
  departmentCode?: string;

  @ApiPropertyOptional({
    description: 'Start date for date range filter (ISO 8601)',
    example: '2024-01-01T00:00:00Z',
  })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({
    description: 'End date for date range filter (ISO 8601)',
    example: '2024-12-31T23:59:59Z',
  })
  @IsOptional()
  @IsDateString()
  endDate?: string;

  @ApiPropertyOptional({
    description: 'Filter by tags (any match)',
    type: [String],
    example: ['urgent', 'priority'],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[];
}
