import { ApiProperty } from '@nestjs/swagger';
import { IsIn, IsNotEmpty, IsOptional, Max, Min } from 'class-validator';
import { PromotionPlanTypes } from '../entities/promotion-plan.entity';
import { AvailableSection } from '../../discount/entities/discount.entity';

export class CreatePromotionPlanDto {
  @ApiProperty({ required: true })
  @IsNotEmpty({ message: 'عنوان طرح اجباری است' })
  name: string;

  @ApiProperty({ required: false })
  @IsOptional()
  customerId: number;

  @ApiProperty({ required: false })
  @Max(100)
  @Min(1)
  @IsOptional()
  discountPercentage: number;

  @ApiProperty({ required: false })
  @IsOptional()
  discountAmount: number;

  @ApiProperty({ required: false })
  @IsOptional()
  validityDays: number;

  @ApiProperty({ required: false })
  @IsOptional()
  startDate?: string | null;

  @ApiProperty({ required: false })
  @IsOptional()
  endDate?: string | null;

  @ApiProperty({ enum: PromotionPlanTypes, required: true })
  @IsNotEmpty()
  @IsIn(Object.values(PromotionPlanTypes))
  type: PromotionPlanTypes;

  @ApiProperty({ enum: AvailableSection, required: true })
  @IsNotEmpty()
  @IsIn(Object.values(AvailableSection))
  section: AvailableSection;
}
