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

export class UpdateReviewDto {
  @IsOptional()
  @IsNumber()
  @Min(1)
  @Max(5)
  @Type(() => Number)
  @ApiPropertyOptional({ description: 'Rating from 1 to 5', minimum: 1, maximum: 5 })
  rating?: number;

  @IsOptional()
  @IsString()
  @ApiPropertyOptional({ description: 'Comment text' })
  comment?: string;

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

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

  @IsOptional()
  @IsEnum(ReviewStatus)
  @ApiPropertyOptional({ description: 'Review status (admin only)', enum: ReviewStatus })
  status?: ReviewStatus;
}
