const mongoose = require('mongoose');

const driverSchema = new mongoose.Schema({
  user_id: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
  name: { type: String, required: true },
  license_number: { type: String, required: true, unique: true },
  license_expiry: { type: Date, required: true },
  phone: { type: String, required: true },
  email: String,
  address: String,
  employment_status: { type: String, enum: ['active','suspended','terminated','on_leave'], default: 'active' },
  hire_date: { type: Date, required: true },
  date_of_birth: Date,
  emergency_contact: String,
  emergency_phone: String,
  total_trips: { type: Number, default: 0 },
  violations: { type: Number, default: 0 },
  accidents: { type: Number, default: 0 },
}, { timestamps: true });

module.exports = mongoose.model('Driver', driverSchema);
