import { Type } from 'class-transformer'
import {
  IsArray,
  IsHexColor,
  IsOptional,
  IsString,
  MaxLength,
  MinLength,
  ValidateNested,
} from 'class-validator'

export class EmailTemplateDto {
  @IsString() @MaxLength(40)
  key!: string

  @IsString() @MaxLength(200)
  subject!: string

  @IsString() @MaxLength(20000)
  body!: string
}

// Customer-editable whitelabel branding. Narrow on purpose: name + accent
// color (written to the Tenant doc) and email-template overrides (written to
// TenantBranding). No plan/status/partner — and no logo/domain yet (no
// backend). brandColor accepts '#rrggbb'.
export class UpdateTenantBrandingDto {
  @IsOptional() @IsString() @MinLength(1) @MaxLength(120)
  name?: string

  @IsOptional() @IsHexColor()
  brandColor?: string

  @IsOptional() @IsArray() @ValidateNested({ each: true }) @Type(() => EmailTemplateDto)
  emailTemplates?: EmailTemplateDto[]
}
