import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsEmail, IsOptional, IsPhoneNumber, IsString, MinLength } from 'class-validator';
import { ESTATE_ID_EXAMPLE } from '../../common/swagger-docs';

export class CreateResidentDto {
  @ApiProperty({ example: ESTATE_ID_EXAMPLE, description: 'Estate that owns this resident.' })
  @IsString()
  estateId!: string;

  @ApiProperty({ example: 'Ade Okafor', description: 'Resident display name.' })
  @IsOptional()
  @IsString()
  @MinLength(2)
  name?: string;

  @ApiProperty({ example: '+2348000000300', description: 'Unique phone number for resident login.' })
  @IsPhoneNumber()
  phone!: string;

  @ApiPropertyOptional({ example: 'A12', description: 'Apartment, unit, house, or flat identifier. Optional at invite time.' })
  @IsOptional()
  @IsString()
  unit?: string;

  @ApiPropertyOptional({ example: 'Ada', description: 'Optional first name.' })
  @IsOptional()
  @IsString()
  firstName?: string;

  @ApiPropertyOptional({ example: 'Okafor', description: 'Optional last name.' })
  @IsOptional()
  @IsString()
  lastName?: string;

  @ApiPropertyOptional({ example: 'Block A', description: 'Optional block number.' })
  @IsOptional()
  @IsString()
  blockNumber?: string;

  @ApiPropertyOptional({ example: 'Flat 12', description: 'Optional flat or apartment number.' })
  @IsOptional()
  @IsString()
  flatNumber?: string;

  @ApiPropertyOptional({ example: 'Block A, Flat 12', description: 'Optional resident address.' })
  @IsOptional()
  @IsString()
  address?: string;

  @ApiPropertyOptional({ example: 'ada@example.com', description: 'Optional resident email.' })
  @IsOptional()
  @IsEmail()
  email?: string;
}
