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

/**
 * Trip Source entity — tenant-scoped.
 *
 * Source Types:
 * - B2B_AGENT: Agent/intermediary, accounting for both guest + source
 * - DIRECT: Direct leads (website, referrals, ads), accounting for guests only
 *
 * Sections:
 * - Source Type Selection
 * - Basic Details: Name, Short Name
 * - Contact Person: Name, Email, Phone (with country code)
 * - Address: City, State, Country, Pin Code, Street, Locality, Landmark
 * - Billing Details: Billing Name, Additional Details
 */
@Entity('trip_sources')
@Unique(['tenant_id', 'short_name'])
export class TripSourceEntity extends BaseEntity {
  // --- Source Type ---
  @Column({ type: 'varchar', length: 50 })
  source_type: string; // B2B_AGENT | DIRECT

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

  @Column({ type: 'varchar', length: 100 })
  short_name: string;

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

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

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

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

  // --- Address ---
  @Column({ type: 'varchar', length: 100, nullable: true })
  city: string | null;

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

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

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

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

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

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

  // --- Billing Details ---
  @Column({ type: 'varchar', length: 255, nullable: true })
  billing_name: string | null;

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

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