const mongoose = require("mongoose");

const employeeSchema = new mongoose.Schema(
  {
    employeeCode: {
      type: String,
      required: [true, "Employee code is required"],
      unique: true,
      trim: true
    },
    firstName: {
      type: String,
      required: [true, "First name is required"],
      trim: true
    },
    lastName: {
      type: String,
      required: [true, "Last name is required"],
      trim: true
    },
    department: {
      type: String,
      required: [true, "Department is required"],
      trim: true
    },
    position: {
      type: String,
      required: [true, "Position is required"],
      trim: true
    },
    baseSalary: {
      type: Number,
      required: [true, "Base salary is required"],
      min: [0, "Salary cannot be negative"]
    },
    hireDate: {
      type: Date,
      required: [true, "Hire date is required"]
    },
    email: {
      type: String,
      trim: true
    },
    phone: {
      type: String,
      trim: true
    }
  },
  { timestamps: true }
);

module.exports = mongoose.model("Employee", employeeSchema);
