// src/dto/discount.dto.ts
import { IsString, IsEnum, IsNumber, IsDateString, IsOptional } from 'class-validator';

export enum DiscountAppliesTo {
  GLOBAL = 'global',
  CATEGORY = 'category',
  PRODUCT = 'product'
}

export class DiscountRequest {
  @IsString()
  name!: string;

  @IsEnum(['percentage', 'fixed'])
  type!: 'percentage' | 'fixed';

  @IsNumber()
  amount!: number;

  @IsDateString()
  start_date!: string;

  @IsDateString()
  @IsOptional()
  end_date?: string;

  @IsNumber()
  @IsOptional()
  min_order_value?: number;

  @IsEnum(DiscountAppliesTo)
  applies_to!: DiscountAppliesTo;

  @IsNumber()
  @IsOptional()
  category_id?: number;

  @IsNumber()
  @IsOptional()
  product_id?: number;
}

export class DiscountResponse {
  discount_id!: number;
  name!: string;
  type!: 'percentage' | 'fixed';
  amount!: number;
  start_date!: Date;
  end_date?: Date;
  min_order_value?: number;
  applies_to!: DiscountAppliesTo;
  category_id?: number;
  product_id?: number;
}