import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsEmail, IsInt, IsObject, IsOptional, IsPhoneNumber, IsString, Min, MinLength } from 'class-validator';

export class CreateEstateDto {
  @ApiProperty({ example: 'GreenPark Estate', description: 'Estate or community name.' })
  @IsString()
  @MinLength(2)
  name!: string;

  @ApiProperty({ example: 'Lagos, Nigeria', description: 'Human-readable estate location.' })
  @IsString()
  location!: string;

  @ApiPropertyOptional({ example: 120, description: 'Number of residents/units/houses in the estate.' })
  @IsOptional()
  @IsInt()
  @Min(0)
  unitCount?: number;

  @ApiPropertyOptional({ example: 'Residential gated community', description: 'Estate type or category.' })
  @IsOptional()
  @IsString()
  estateType?: string;

  @ApiPropertyOptional({
    example: { timezone: 'Africa/Lagos', gates: ['Main Gate'] },
    description: 'Operational settings stored as JSON.'
  })
  @IsOptional()
  @IsObject()
  settings?: Record<string, unknown>;

  @ApiPropertyOptional({
    example: { primaryColor: '#0f766e' },
    description: 'Branding configuration stored as JSON.'
  })
  @IsOptional()
  @IsObject()
  branding?: Record<string, unknown>;

  @ApiPropertyOptional({ example: 'Ade Okafor', description: 'Optional estate admin name to register with the estate.' })
  @IsOptional()
  @IsString()
  adminName?: string;

  @ApiPropertyOptional({ example: '+2348000000990', description: 'Optional estate admin phone to register with the estate.' })
  @IsOptional()
  @IsPhoneNumber()
  adminPhone?: string;

  @ApiPropertyOptional({ example: 'estate.admin@example.com', description: 'Optional estate admin email stored in onboarding settings.' })
  @IsOptional()
  @IsEmail()
  adminEmail?: string;
}
