import { BaseEntity } from "@edr/api-common";
import { Freight } from "@edr/types";
import { Column, Entity } from "typeorm";

@Entity({schema:"freight", name: "consignments" })
export class Consignment extends BaseEntity {
  @Column({ name: "booking_id", type: "uuid" })
  bookingId!: string;

  @Column({
    name: "tracking_number",
    type: "varchar",
    length: 64,
    unique: true,
  })
  trackingNumber!: string;

  @Column({ name: "cargo_type", type: "enum", enum: Freight.CargoType })
  cargoType!: Freight.CargoType;

  @Column({ name: "weight_kg", type: "numeric", precision: 12, scale: 2 })
  weightKg!: number;

  @Column({
    name: "status",
    type: "enum",
    enum: Freight.ConsignmentStatus,
    default: Freight.ConsignmentStatus.Pending,
  })
  status!: Freight.ConsignmentStatus;

  @Column({ name: "origin_station", type: "varchar", length: 128 })
  originStation!: string;

  @Column({ name: "destination_station", type: "varchar", length: 128 })
  destinationStation!: string;
}
