import { Entity, Column, ManyToOne, JoinColumn } from 'typeorm';
import { BaseEntity } from '../database/base.entity';
import { ActivityTicketItemEntity } from './activity-ticket-item.entity';

export enum TicketJourneyEvent {
  UPLOADED = 'UPLOADED',
  ASSIGNED = 'ASSIGNED',
  UNASSIGNED = 'UNASSIGNED',
  REFUNDED = 'REFUNDED',
  CANCELLED = 'CANCELLED',
  REUSED = 'REUSED',
  MOVED_TO_USED = 'MOVED_TO_USED',
  MOVED_TO_UNUSED = 'MOVED_TO_UNUSED',
}

@Entity('activity_ticket_journeys')
export class ActivityTicketJourneyEntity extends BaseEntity {
  @ManyToOne(() => ActivityTicketItemEntity, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'ticket_item_id' })
  ticket_item: ActivityTicketItemEntity;

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

  @Column({ type: 'varchar', length: 30 })
  event: string; // TicketJourneyEvent value

  /** Booking ID this event relates to (null for upload events). */
  @Column({ type: 'uuid', nullable: true })
  booking_id: string | null;

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

  /** File path before the event (for move tracking). */
  @Column({ type: 'varchar', length: 500, nullable: true })
  from_path: string | null;

  /** File path after the event. */
  @Column({ type: 'varchar', length: 500, nullable: true })
  to_path: string | null;

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