import { ApiPropertyOptional } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsIn, IsOptional, IsString } from 'class-validator';
import { PaginationQueryDto } from '../../../common/dto/pagination-query.dto';
import {
  SUPERADMIN_CASE_PRIORITIES,
  SUPERADMIN_CASE_STATUSES,
} from '../schemas/superadmin-case.schema';

export class SuperAdminCaseQueryDto extends PaginationQueryDto {
  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  q?: string;

  @ApiPropertyOptional({ enum: SUPERADMIN_CASE_STATUSES })
  @IsOptional()
  @Transform(({ value }) => (typeof value === 'string' ? value.trim().toLowerCase() : value))
  @IsIn(SUPERADMIN_CASE_STATUSES)
  status?: (typeof SUPERADMIN_CASE_STATUSES)[number];

  @ApiPropertyOptional({ enum: SUPERADMIN_CASE_PRIORITIES })
  @IsOptional()
  @Transform(({ value }) => (typeof value === 'string' ? value.trim().toLowerCase() : value))
  @IsIn(SUPERADMIN_CASE_PRIORITIES)
  priority?: (typeof SUPERADMIN_CASE_PRIORITIES)[number];

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  resourceType?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  assignedTo?: string;
}
