import { ProjectStatus } from "@prisma/client";
import { IsUUID, IsEnum, IsOptional, IsInt, Min, Max, IsDateString } from "class-validator";
import { Type } from "class-transformer";

/**
 * DTO for querying projects with filters and pagination
 */
export class QueryProjectsDto {
  @IsOptional()
  @IsUUID("4", { message: "workspaceId must be a valid UUID" })
  workspaceId?: string;

  @IsOptional()
  @IsEnum(ProjectStatus, { message: "status must be a valid ProjectStatus" })
  status?: ProjectStatus;

  @IsOptional()
  @IsDateString({}, { message: "startDateFrom must be a valid ISO 8601 date string" })
  startDateFrom?: Date;

  @IsOptional()
  @IsDateString({}, { message: "startDateTo must be a valid ISO 8601 date string" })
  startDateTo?: Date;

  @IsOptional()
  @Type(() => Number)
  @IsInt({ message: "page must be an integer" })
  @Min(1, { message: "page must be at least 1" })
  page?: number;

  @IsOptional()
  @Type(() => Number)
  @IsInt({ message: "limit must be an integer" })
  @Min(1, { message: "limit must be at least 1" })
  @Max(100, { message: "limit must not exceed 100" })
  limit?: number;
}
