import { IsBoolean, IsEnum, IsIn, IsNotEmpty, IsNumber, IsOptional, IsString, MaxLength, Min } from 'class-validator';
import { ProductCategory } from '@prisma/client';
import { GST_RATES, PRODUCT_UNITS } from '../product.constants';

export class CreateProductDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(255)
  name!: string;

  @IsString()
  @IsOptional()
  @MaxLength(100)
  sku?: string;

  @IsEnum(ProductCategory)
  @IsOptional()
  category?: ProductCategory;

  @IsOptional()
  @IsIn(PRODUCT_UNITS, { message: 'Select a valid unit' })
  unit?: string;

  @IsNumber()
  @Min(0)
  @IsOptional()
  price?: number;

  @IsOptional()
  @IsIn(GST_RATES, { message: 'Select a valid GST rate' })
  gstRate?: number;

  @IsString()
  @IsOptional()
  @MaxLength(50)
  hsnSac?: string;

  @IsString()
  @IsOptional()
  description?: string;

  @IsBoolean()
  @IsOptional()
  isActive?: boolean;
}
