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

/**
 * Destination entity — tenant-scoped.
 *
 * Sections:
 * - Basic Details: Name, Short Code, Country, City, Currency (FK), Timezone, Description, Image
 * - Visa Information: Visa Required (boolean)
 * - Services: Available service types (hotels, transport, activities)
 */
@Entity('destinations')
@Unique(['tenant_id', 'short_code'])
export class DestinationEntity extends BaseEntity {
  // --- Basic Details ---
  @Column({ type: 'varchar', length: 255 })
  name: string;

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

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

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

  @ManyToOne(() => CurrencyEntity)
  @JoinColumn({ name: 'currency_id' })
  currency: CurrencyEntity;

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

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

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

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

  // --- Visa Information ---
  @Column({ type: 'boolean', default: false })
  visa_required: boolean;

  // --- Tax Types applicable at this destination ---
  @Column({ type: 'jsonb', nullable: true })
  tax_types: string[] | null;

  // --- Services available at this destination ---
  @Column({ type: 'simple-json', nullable: true })
  services: string[] | null;
}
