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

/**
 * ActivityTicket entity — tenant-scoped child of Activity.
 *
 * Each activity can have multiple ticket types (e.g. General Admission, VIP, Fast Track).
 * Referenced by: Activity Pricing, Quotation, Booking modules.
 */
@Entity('activity_tickets')
@Unique(['tenant_id', 'activity_id', 'name'])
export class ActivityTicketEntity extends BaseEntity {
  @ManyToOne(() => ActivityEntity, (activity) => activity.tickets, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'activity_id' })
  activity: ActivityEntity;

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

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

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

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

  @Column({ type: 'int', nullable: true })
  duration_mins: number | null;

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

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