const mongoose = require('mongoose');

const employeeSchema = new mongoose.Schema({
    id: String,
    smartCardId: String,
    firstName: String,
    lastName: String,
    shortNumber: Number,
    employeeRoleId: Number,
    employeeRoleName: String,
    firstLogin: Boolean,
    loginAttempts: Number,
    locked: Boolean,
    companyName: String,
    type: String,
    permissions: [{
        id: String,
        name: String
    }],
    remainingSamProvisionCount: Number,
    languageCodes: Array,
    lastLoginDate: Date,
    lastChangedTimestamp: Date,
    lastModified: Date,
    remainingLoginAttempts: Number,
    organizationExternalId: String,
    externalReference: String,
    employeeRoleExternalReference: String,
    employeeRoleExternalId: Number,
    userName: String,
    password: String
});

const employeeRoleSchema = new mongoose.Schema({
    fareEnvironmentConfigurationId: String,
    employeeRoleId: Number,
    employeeRoleName: String,
    employeeRoleLongName: String
});

const employeeWorkTimeSchema = new mongoose.Schema({
    employeeId: String,
    firstName: String,
    lastName: String,
    employeeRoleId: String,
    employeeRoleName: String,
    loginTime: Date,
    logoutTime: Date,
    startBalanceAmount: Number,
    endBalanceAmount: Number,
    diffBalanceAmount: Number,
    locked: [{
        start: Date,
        end: Date
    }],
    sessionId: Number
});

const Employee = mongoose.model('Employee', employeeSchema);

const EmployeeRole = mongoose.model('EmployeeRole', employeeRoleSchema);

const EmployeeWorkTime = mongoose.model('EmployeeWorkTime', employeeWorkTimeSchema);

module.exports = {
    Employee,
    EmployeeRole,
    EmployeeWorkTime
};
