// ============================================================
// Shared DTOs fuer Multi-Value E-Mails und Telefonnummern
// ============================================================

import {
  IsString,
  IsOptional,
  IsEnum,
  IsBoolean,
  IsEmail,
  MaxLength,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

// --------------------------------------------------------
// Enums (TS-Pendants zu Prisma Enums)
// --------------------------------------------------------

export enum EmailType {
  WORK = 'WORK',
  PERSONAL = 'PERSONAL',
  OTHER = 'OTHER',
}

export enum PhoneType {
  OFFICE = 'OFFICE',
  MOBILE = 'MOBILE',
  FAX = 'FAX',
}

export enum ContactSource {
  TRADE_FAIR = 'TRADE_FAIR',
  REFERRAL = 'REFERRAL',
  WEBSITE = 'WEBSITE',
  COLD_CALL = 'COLD_CALL',
  IMPORT = 'IMPORT',
  BUSINESS_CARD = 'BUSINESS_CARD',
  OTHER = 'OTHER',
}

export enum EntityStatus {
  ACTIVE = 'ACTIVE',
  INACTIVE = 'INACTIVE',
  BLOCKED = 'BLOCKED',
}

export enum CompanySize {
  SIZE_1_10 = 'SIZE_1_10',
  SIZE_11_50 = 'SIZE_11_50',
  SIZE_51_200 = 'SIZE_51_200',
  SIZE_201_500 = 'SIZE_201_500',
  SIZE_500_PLUS = 'SIZE_500_PLUS',
}

// --------------------------------------------------------
// DTOs
// --------------------------------------------------------

export class CreateEmailDto {
  @ApiProperty({ maxLength: 255, description: 'E-Mail-Adresse' })
  @IsEmail()
  @MaxLength(255)
  email!: string;

  @ApiPropertyOptional({ enum: EmailType, default: EmailType.WORK })
  @IsOptional()
  @IsEnum(EmailType)
  type?: EmailType;

  @ApiPropertyOptional({ default: false })
  @IsOptional()
  @IsBoolean()
  isPrimary?: boolean;
}

export class CreatePhoneDto {
  @ApiProperty({ maxLength: 50, description: 'Telefonnummer' })
  @IsString()
  @MaxLength(50)
  phone!: string;

  @ApiPropertyOptional({ enum: PhoneType, default: PhoneType.OFFICE })
  @IsOptional()
  @IsEnum(PhoneType)
  type?: PhoneType;

  @ApiPropertyOptional({ default: false })
  @IsOptional()
  @IsBoolean()
  isPrimary?: boolean;
}
