import { BaseEntity } from '@edr/api-common';
import { Column, Entity, Index } from 'typeorm';

export const WAREHOUSE_ACTIVITY_TYPES = [
  'INVENTORY_RECEIVED',
  'INVENTORY_UNLOADED',
  'INVENTORY_STORED',
  'INVENTORY_MOVED',
  'INVENTORY_RESERVED',
  'READY_FOR_LOADING',
  'INVENTORY_LOADED',
  'INVENTORY_DISPATCHED',
  'READY_FOR_PICKUP',
  'INVENTORY_RELEASED',
  'INVENTORY_DELIVERED',
] as const;
export type WarehouseActivityType = (typeof WAREHOUSE_ACTIVITY_TYPES)[number];

@Entity({ schema: 'freight', name: 'warehouse_activity_log' })
@Index(['inventoryId'])
@Index(['warehouseId'])
@Index(['activityType'])
export class WarehouseActivityLog extends BaseEntity {
  @Column({ name: 'inventory_id', type: 'uuid', nullable: true })
  inventoryId?: string | null;

  @Column({ name: 'warehouse_id', type: 'uuid', nullable: true })
  warehouseId?: string | null;

  @Column({ name: 'activity_type', type: 'varchar', length: 40 })
  activityType!: WarehouseActivityType;

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

  @Column({ name: 'performed_by', type: 'varchar', length: 120, nullable: true })
  performedBy?: string | null;
}
