import {
  IsString,
  IsOptional,
  IsNumber,
  IsArray,
  ArrayNotEmpty,
  IsNotEmpty,
} from 'class-validator';
import { Type } from 'class-transformer';
import { CompanyDocumentDto } from './company-document.dto';

export class CreateCompanyDto {
  @IsString()
  name: string; // ✅ REQUIRED

  @IsString()
  @IsOptional()
  address?: string;

  @IsString()
  @IsOptional()
  city?: string;

  @IsString()
  @IsOptional()
  contact_person?: string;

  @IsString()
  @IsOptional()
  designation?: string;

  @IsString()
  @IsOptional()
  email?: string;

  @IsString()
  @IsOptional()
  mobile?: string;

  @IsString()
  @IsOptional()
  telephone?: string;

  @IsString()
  @IsOptional()
  fax?: string;

  @IsString()
  @IsOptional()
  validity?: string;

  @IsString()
  @IsOptional()
  certification_body?: string;

  // ✅ NEW — Client group / team
  @IsString({ message: 'Client group must be a string' })
  @IsNotEmpty({ message: 'Client group is required' })
  client_group: string;

  @IsString()
  @IsOptional()
  accreditation?: string;

  @IsString()
  scope_of_work: string; // ✅ REQUIRED

  @IsNumber()
  @IsOptional()
  country_id?: number;

  @IsArray()
  @ArrayNotEmpty()
  standards: number[]; // ✅ REQUIRED — at least one standard

  @IsOptional()
  @IsString()
  reference_number?: string;

  @IsOptional()
  @IsArray()
  @Type(() => CompanyDocumentDto)
  documents?: CompanyDocumentDto[];
}
