import { ApiPropertyOptional } from "@nestjs/swagger"
import { IsDateString, IsEnum, IsInt, IsOptional, Min } from "class-validator"
import { Type } from "class-transformer"

export enum TripType {
  REQUESTS = "requests",
  UPCOMING = "upcoming",
  PAST = "past",
}

export enum PastTripType {
  COMPLETED = "completed",
  CANCELLED = "cancelled",
  ALL = "all",
}

export class GetTripsQueryDto {
  @ApiPropertyOptional({
    enum: TripType,
    description: "Type of trips to retrieve",
  })
  @IsOptional()
  @IsEnum(TripType)
  type?: TripType

  @ApiPropertyOptional({
    description: "Page number for pagination",
    default: 1,
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1

  @ApiPropertyOptional({
    description: "Limit of items per page for pagination",
    default: 10,
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  limit?: number = 10

  @ApiPropertyOptional({
    enum: PastTripType,
    description:
      "Type of past trips to retrieve (only applicable when type is 'past')",
  })
  @IsOptional()
  @IsEnum(PastTripType)
  pastTripType?: PastTripType

  @ApiPropertyOptional({
    description:
      "Filter upcoming trips to this date and future (ISO date YYYY-MM-DD, only applicable when type is 'upcoming')",
    example: "2025-02-13",
  })
  @IsOptional()
  @IsDateString()
  fromDate?: string
}
