import { Type } from 'class-transformer'
import { IsBoolean, IsEnum, IsInt, IsOptional, Min, ValidateNested } from 'class-validator'

// Per-currency amount sub-object. Each currency is optional — a plan that
// isn't sold in EUR just leaves EUR undefined. Stored in minor units.
class AmountsDto {
  @IsOptional() @IsInt() @Min(0) DKK?: number
  @IsOptional() @IsInt() @Min(0) EUR?: number
  @IsOptional() @IsInt() @Min(0) USD?: number
}

export class CreatePriceDto {
  @IsEnum(['mvp', 'pro', 'enterprise'])
  plan!: 'mvp' | 'pro' | 'enterprise'

  @IsEnum(['monthly', 'quarterly', 'yearly'])
  cycle!: 'monthly' | 'quarterly' | 'yearly'

  @ValidateNested() @Type(() => AmountsDto)
  amounts!: AmountsDto

  @IsOptional() @IsBoolean()
  active?: boolean
}
