/**
 * Work Bay Entity
 * Mecánicas Diesel - ERP Suite
 *
 * Represents work bays in the workshop.
 */

import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  Index,
} from 'typeorm';

export enum BayType {
  GENERAL = 'general',
  DIAGNOSTIC = 'diagnostic',
  HEAVY_DUTY = 'heavy_duty',
  QUICK_SERVICE = 'quick_service',
}

export enum BayStatus {
  AVAILABLE = 'available',
  OCCUPIED = 'occupied',
  MAINTENANCE = 'maintenance',
}

@Entity({ name: 'work_bays', schema: 'service_management' })
@Index('idx_bays_tenant', ['tenantId'])
@Index('idx_bays_status', ['tenantId', 'status'])
export class WorkBay {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'tenant_id', type: 'uuid' })
  tenantId: string;

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

  @Column({ type: 'varchar', length: 200, nullable: true })
  description?: string;

  @Column({ name: 'bay_type', type: 'varchar', length: 50, nullable: true })
  bayType?: BayType;

  @Column({
    type: 'varchar',
    length: 20,
    default: BayStatus.AVAILABLE,
  })
  status: BayStatus;

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

  // Capacity
  @Column({ name: 'max_weight', type: 'decimal', precision: 10, scale: 2, nullable: true })
  maxWeight?: number;

  @Column({ name: 'has_lift', type: 'boolean', default: false })
  hasLift: boolean;

  @Column({ name: 'has_pit', type: 'boolean', default: false })
  hasPit: boolean;

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

  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
  updatedAt: Date;
}
