import {
  IsString,
  IsOptional,
  IsNumber,
  IsArray,
  IsInt,
  Min,
  Max,
  IsDateString,
  IsUUID,
  MaxLength,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';

export class BatchIssueDto {
  @ApiProperty({ description: 'UUID of the coupon template to clone' })
  @IsUUID()
  templateId: string;

  @ApiProperty({ minimum: 1, maximum: 10000 })
  @IsInt()
  @Min(1)
  @Max(10000)
  quantity: number;

  @ApiPropertyOptional({ description: 'ISO 8601 date for expiry' })
  @IsOptional()
  @IsDateString()
  expiryDate?: string;
}

export class BatchRecallDto {
  @ApiProperty({ type: [String], description: 'Array of coupon UUIDs to recall' })
  @IsArray()
  @IsUUID('4', { each: true })
  couponIds: string[];

  @ApiProperty({ maxLength: 1000 })
  @IsString()
  @MaxLength(1000)
  reason: string;
}

export class BatchPriceAdjustDto {
  @ApiProperty({ type: [String], description: 'Array of coupon UUIDs to adjust' })
  @IsArray()
  @IsUUID('4', { each: true })
  couponIds: string[];

  @ApiProperty({ description: 'Percent adjustment (-50 to +100)', minimum: -50, maximum: 100 })
  @IsNumber()
  @Min(-50)
  @Max(100)
  adjustPercent: number;
}

export class ListBatchOperationsQueryDto {
  @ApiPropertyOptional({ default: 1 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  page?: number = 1;

  @ApiPropertyOptional({ default: 20 })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  @Min(1)
  @Max(100)
  limit?: number = 20;
}
