import {
  IsString,
  IsNotEmpty,
  IsEnum,
  IsOptional,
  IsBoolean,
  IsArray,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { EmailType } from '@prisma/client';

export class UpsertEmailTemplateDto {
  @ApiProperty({ description: 'Email type', enum: EmailType })
  @IsEnum(EmailType)
  type: EmailType;

  @ApiProperty({ description: 'Email subject (supports {{variables}})' })
  @IsString()
  @IsNotEmpty()
  subject: string;

  @ApiProperty({ description: 'HTML body (Handlebars template)' })
  @IsString()
  @IsNotEmpty()
  bodyHtml: string;

  @ApiPropertyOptional({ description: 'Plain text body (Handlebars template)' })
  @IsString()
  @IsOptional()
  bodyText?: string;

  @ApiPropertyOptional({
    description: 'List of variable names used in the template',
    example: ['clientName', 'clubName', 'trainerName'],
  })
  @IsArray()
  @IsString({ each: true })
  @IsOptional()
  variables?: string[];

  @ApiPropertyOptional({ description: 'Enable/disable the template' })
  @IsBoolean()
  @IsOptional()
  isActive?: boolean;
}
