import { IsNotEmpty, IsNumber, IsOptional, IsString, Max, Min, IsArray, IsEnum } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { PositivePoint, NegativePoint } from '../enums/review-point.enum';

export class CreateReviewDto {
  @IsNotEmpty()
  @IsString()
  @ApiProperty({ description: 'Food ID' })
  foodId: string;

  @IsNotEmpty()
  @IsString()
  @ApiProperty({ description: 'Order ID' })
  orderId: string;

  @IsNotEmpty()
  @IsNumber()
  @Min(1)
  @Max(5)
  @Type(() => Number)
  @ApiProperty({ description: 'Rating from 1 to 5', example: 5, minimum: 1, maximum: 5 })
  rating: number;

  @IsOptional()
  @IsString()
  @ApiPropertyOptional({ description: 'Comment text', example: 'Very delicious food!' })
  comment?: string;

  @IsOptional()
  @IsArray()
  @IsEnum(PositivePoint, { each: true })
  @ApiPropertyOptional({
    description: 'Positive points about the food',
    example: [PositivePoint.GREAT_TASTE, PositivePoint.FAST_DELIVERY],
    enum: PositivePoint,
    isArray: true,
  })
  positivePoints?: PositivePoint[];

  @IsOptional()
  @IsArray()
  @IsEnum(NegativePoint, { each: true })
  @ApiPropertyOptional({
    description: 'Negative points about the food',
    example: [NegativePoint.SMALL_PORTION],
    enum: NegativePoint,
    isArray: true,
  })
  negativePoints?: NegativePoint[];
}
