/**
 * Person Entity
 * Contact/person information with identity verification
 * Compatible with erp-core person.entity
 *
 * @module Profiles
 */

import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
  Index,
} from 'typeorm';

@Entity({ name: 'persons', schema: 'auth' })
export class Person {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'full_name', type: 'varchar', length: 200 })
  fullName: string;

  @Column({ name: 'first_name', type: 'varchar', length: 100, nullable: true })
  firstName: string;

  @Column({ name: 'last_name', type: 'varchar', length: 100, nullable: true })
  lastName: string;

  @Column({ name: 'maternal_name', type: 'varchar', length: 100, nullable: true })
  maternalName: string;

  @Index()
  @Column({ type: 'varchar', length: 255 })
  email: string;

  @Column({ type: 'varchar', length: 20, nullable: true })
  phone: string;

  @Column({ name: 'mobile_phone', type: 'varchar', length: 20, nullable: true })
  mobilePhone: string;

  @Column({ name: 'identification_type', type: 'varchar', length: 50, nullable: true })
  identificationType: string;

  @Column({ name: 'identification_number', type: 'varchar', length: 50, nullable: true })
  identificationNumber: string;

  @Column({ name: 'identification_expiry', type: 'date', nullable: true })
  identificationExpiry: Date;

  @Column({ type: 'jsonb', default: {} })
  address: Record<string, any>;

  @Column({ name: 'is_verified', type: 'boolean', default: false })
  isVerified: boolean;

  @Column({ name: 'verified_at', type: 'timestamptz', nullable: true })
  verifiedAt: Date;

  @Column({ name: 'verified_by', type: 'uuid', nullable: true })
  verifiedBy: string;

  @Column({ name: 'is_responsible_for_tenant', type: 'boolean', default: false })
  isResponsibleForTenant: boolean;

  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
  updatedAt: Date;

  @DeleteDateColumn({ name: 'deleted_at', type: 'timestamptz', nullable: true })
  deletedAt: Date;
}
