import { IsInt, IsOptional, IsString, MaxLength } from 'class-validator';
import { Type } from 'class-transformer';

/**
 * Body for POST /leads/:id/assign — the dedicated handover endpoint.
 *
 * Reassignment deliberately does NOT go through PATCH /leads/:id any more.
 * A handover has its own permission ('assign'), its own activity entry, and
 * its own notification + email fan-out; folding it into the generic update
 * made all three easy to trigger by accident from an unrelated field edit.
 */
export class AssignLeadDto {
  /** The user who will own the lead after this call. */
  @IsInt()
  @Type(() => Number)
  assigned_to: number;

  /** Optional handover note — included in the notification and the email. */
  @IsOptional()
  @IsString()
  @MaxLength(1000)
  note?: string;

  /**
   * Set false to move the lead without pinging anyone (bulk cleanups,
   * data migrations). Defaults to true.
   */
  @IsOptional()
  notify?: boolean;
}
