import {
  IsInt,
  IsNotEmpty,
  IsOptional,
  IsString,
  IsArray,
  Min,
  Max,
} from "class-validator"
import { ApiProperty } from "@nestjs/swagger"
import { RatingType, RATING_TYPES } from "../constants/rating-type.constants"

export class CreateRatingDto {
  @ApiProperty({
    description:
      "ID of the entity giving the rating (e.g., TeamMember or Customer)",
  })
  @IsInt()
  @IsNotEmpty()
  rater_id: number

  @ApiProperty({
    description: "ID of the entity being rated (e.g., TeamMember or Customer)",
  })
  @IsInt()
  @IsNotEmpty()
  rated_id: number

  @ApiProperty({ description: "ID of the trip associated with the rating" })
  @IsInt()
  @IsNotEmpty()
  trip_id: number

  @ApiProperty({
    description: "The rating value (1-5 stars)",
    minimum: 1,
    maximum: 5,
  })
  @IsInt()
  @IsNotEmpty()
  @Min(1)
  @Max(5)
  rating: number

  @ApiProperty({
    description: "Optional additional input or comments for the rating",
    required: false,
  })
  @IsOptional()
  @IsString()
  other_input?: string

  @ApiProperty({
    description:
      "The type of rating (e.g., DRIVER_TO_CUSTOMER, CUSTOMER_TO_DRIVER)",
    enum: RATING_TYPES,
  })
  @IsNotEmpty()
  @IsString()
  rating_type: RatingType

  @ApiProperty({
    description:
      'Optional array of tags associated with the rating (e.g., ["polite", "friendly"])',
    type: [String],
    required: false,
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[]
}
