import { PropertyType, Direction } from '@prisma/client';
import { AggregateRoot } from '@modules/shared';
import { Address } from '../value-objects/address.vo';
import { GeoPoint } from '../value-objects/geo-point.vo';

export interface PropertyProps {
  propertyType: PropertyType;
  title: string;
  description: string;
  address: Address;
  location: GeoPoint;
  areaM2: number;
  usableAreaM2: number | null;
  bedrooms: number | null;
  bathrooms: number | null;
  floors: number | null;
  floor: number | null;
  totalFloors: number | null;
  direction: Direction | null;
  yearBuilt: number | null;
  legalStatus: string | null;
  amenities: unknown;
  nearbyPOIs: unknown;
  metroDistanceM: number | null;
  projectName: string | null;
}

export class PropertyEntity extends AggregateRoot<string> {
  private _propertyType: PropertyType;
  private _title: string;
  private _description: string;
  private _address: Address;
  private _location: GeoPoint;
  private _areaM2: number;
  private _usableAreaM2: number | null;
  private _bedrooms: number | null;
  private _bathrooms: number | null;
  private _floors: number | null;
  private _floor: number | null;
  private _totalFloors: number | null;
  private _direction: Direction | null;
  private _yearBuilt: number | null;
  private _legalStatus: string | null;
  private _amenities: unknown;
  private _nearbyPOIs: unknown;
  private _metroDistanceM: number | null;
  private _projectName: string | null;

  constructor(id: string, props: PropertyProps, createdAt?: Date, updatedAt?: Date) {
    super(id, createdAt, updatedAt);
    this._propertyType = props.propertyType;
    this._title = props.title;
    this._description = props.description;
    this._address = props.address;
    this._location = props.location;
    this._areaM2 = props.areaM2;
    this._usableAreaM2 = props.usableAreaM2;
    this._bedrooms = props.bedrooms;
    this._bathrooms = props.bathrooms;
    this._floors = props.floors;
    this._floor = props.floor;
    this._totalFloors = props.totalFloors;
    this._direction = props.direction;
    this._yearBuilt = props.yearBuilt;
    this._legalStatus = props.legalStatus;
    this._amenities = props.amenities;
    this._nearbyPOIs = props.nearbyPOIs;
    this._metroDistanceM = props.metroDistanceM;
    this._projectName = props.projectName;
  }

  get propertyType(): PropertyType { return this._propertyType; }
  get title(): string { return this._title; }
  get description(): string { return this._description; }
  get address(): Address { return this._address; }
  get location(): GeoPoint { return this._location; }
  get areaM2(): number { return this._areaM2; }
  get usableAreaM2(): number | null { return this._usableAreaM2; }
  get bedrooms(): number | null { return this._bedrooms; }
  get bathrooms(): number | null { return this._bathrooms; }
  get floors(): number | null { return this._floors; }
  get floor(): number | null { return this._floor; }
  get totalFloors(): number | null { return this._totalFloors; }
  get direction(): Direction | null { return this._direction; }
  get yearBuilt(): number | null { return this._yearBuilt; }
  get legalStatus(): string | null { return this._legalStatus; }
  get amenities(): unknown { return this._amenities; }
  get nearbyPOIs(): unknown { return this._nearbyPOIs; }
  get metroDistanceM(): number | null { return this._metroDistanceM; }
  get projectName(): string | null { return this._projectName; }

  static createNew(id: string, props: PropertyProps): PropertyEntity {
    return new PropertyEntity(id, props);
  }
}
