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

export enum VehicleType {
  TRUCK = 'TRUCK',
  VAN = 'VAN',
  CAR = 'CAR',
  BUS = 'BUS',
  TRAILER = 'TRAILER',
  TANKER = 'TANKER',
  FLATBED = 'FLATBED',
}

export enum FuelType {
  PETROL = 'PETROL',
  DIESEL = 'DIESEL',
  ELECTRIC = 'ELECTRIC',
  HYBRID = 'HYBRID',
}

export enum VehicleStatus {
  ACTIVE = 'ACTIVE',
  MAINTENANCE = 'MAINTENANCE',
  RETIRED = 'RETIRED',
  OUT_OF_SERVICE = 'OUT_OF_SERVICE',
}

@Entity({ name: 'vehicles', schema: 'freight' })
export class Vehicle extends BaseEntity {
  @Column({ name: 'plate_number', unique: true, nullable: true })
  plateNumber?: string;

  @Column({ name: 'registration_number', unique: true, nullable: true })
  registrationNumber?: string;

  @Column({ name: 'vehicle_type', type: 'varchar', nullable: true })
  vehicleType?: VehicleType;

  @Column({ nullable: true })
  manufacturer?: string;

  @Column({ nullable: true })
  model?: string;

  @Column({ nullable: true })
  year?: number;

  @Column({ name: 'fuel_type', type: 'varchar', nullable: true })
  fuelType?: FuelType;

  @Column({ nullable: true })
  capacity?: number;

  @Column({ name: 'status', type: 'varchar', default: VehicleStatus.ACTIVE, nullable: true })
  status?: VehicleStatus;

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

  @Column({ name: 'assigned_driver_id', type: 'uuid', nullable: true })
  assignedDriverId?: string;

  @Column({ name: 'assigned_driver_name', nullable: true })
  assignedDriverName?: string;
}
