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

export class SendEmailDto {
  @ApiProperty({ description: 'Recipient email address' })
  @IsEmail()
  @IsNotEmpty()
  recipientEmail: string;

  @ApiPropertyOptional({ description: 'Client UUID (for tracking)' })
  @IsUUID()
  @IsOptional()
  clientId?: string;

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

  @ApiPropertyOptional({
    description: 'Template variables for Handlebars rendering',
    example: { clientName: 'Иван', trainerName: 'Алексей' },
  })
  @IsObject()
  @IsOptional()
  variables?: Record<string, string>;

  @ApiPropertyOptional({ description: 'Custom subject (overrides template)' })
  @IsString()
  @IsOptional()
  subject?: string;

  @ApiPropertyOptional({ description: 'Custom body HTML (overrides template)' })
  @IsString()
  @IsOptional()
  bodyHtml?: string;
}
