import { Entity, Column, Unique, ManyToOne, JoinColumn } from 'typeorm';
import { BaseEntity } from '../database/base.entity';
import { DestinationEntity } from './destination.entity';

/**
 * Hotel entity — tenant-scoped.
 *
 * Linked to Destination via FK. Unique hotel name per destination per tenant.
 *
 * Sections:
 * - Basic Details: Name, Destination, Address, Location
 * - GPS & Access: GPS coordinates, Pickup/Dropoff Gates
 * - Contact: Contact Person, Phone
 * - Additional Info: Special Instructions, Meeting Point
 */
@Entity('hotels')
@Unique(['tenant_id', 'name', 'destination_id'])
@Unique(['tenant_id', 'short_code'])
export class HotelEntity extends BaseEntity {
  // --- Destination FK ---
  @ManyToOne(() => DestinationEntity)
  @JoinColumn({ name: 'destination_id' })
  destination: DestinationEntity;

  @Column({ type: 'uuid' })
  destination_id: string;

  // --- Basic Details ---
  @Column({ type: 'varchar', length: 50 })
  short_code: string;

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

  @Column({ type: 'varchar', length: 500 })
  address: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  location: string | null;

  // --- GPS & Access ---
  @Column({ type: 'varchar', length: 20, nullable: true })
  gps_latitude: string | null;

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

  @Column({ type: 'varchar', length: 255, nullable: true })
  pickup_gate: string | null;

  @Column({ type: 'varchar', length: 255, nullable: true })
  dropoff_gate: string | null;

  // --- Contact ---
  @Column({ type: 'varchar', length: 255 })
  contact_person: string;

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

  // --- Additional Info ---
  @Column({ type: 'text', nullable: true })
  special_instructions: string | null;

  @Column({ type: 'text', nullable: true })
  meeting_point: string | null;

  // --- Status ---
  @Column({ type: 'boolean', default: true })
  is_active: boolean;
}
