diff --git a/public/uploads/Add-PD.xlsx b/public/uploads/Add-PD.xlsx index 21ce549..b17fe24 100644 Binary files a/public/uploads/Add-PD.xlsx and b/public/uploads/Add-PD.xlsx differ diff --git a/resources/Leaves/LeaveModel.js b/resources/Leaves/LeaveModel.js index bd50258..383d0fd 100644 --- a/resources/Leaves/LeaveModel.js +++ b/resources/Leaves/LeaveModel.js @@ -12,7 +12,7 @@ const leaveRecordSchema = new mongoose.Schema({ }, location: { type: String, - required: true, + // required: true, }, reason: { type: String, @@ -21,7 +21,7 @@ const leaveRecordSchema = new mongoose.Schema({ leaveType: { type: String, required: true, - enum: ["Sick Leave", "Casual Leave"], + enum: ["Sick Leave", "Privilege Leave","Personal Leave"], }, }); diff --git a/resources/user/userController.js b/resources/user/userController.js index 3ec8cf6..b4fd460 100644 --- a/resources/user/userController.js +++ b/resources/user/userController.js @@ -932,7 +932,7 @@ export const getUserOrderForAdmin = async (req, res) => { }; // 8.update User password export const updatePassword = catchAsyncErrors(async (req, res, next) => { - const user = await User.findById(req.user.id).select("+password"); + const user = await User.findById(req.user._id).select("+password"); const isPasswordMatched = await user.comparePassword(req.body.oldPassword); diff --git a/resources/user/userModel.js b/resources/user/userModel.js index 79f92e2..69024be 100644 --- a/resources/user/userModel.js +++ b/resources/user/userModel.js @@ -11,11 +11,29 @@ const userSchema = new mongoose.Schema( uniqueId: { type: String, unique: true, - required: true, + validate: { + validator: function (value) { + // Only require uniqueId if the role is not "admin" + if (this.role !== "admin" && !value) { + return false; + } + return true; + }, + message: "Unique ID is required for users", + }, }, SBU: { type: String, - required: [true, "Please Enter Your SBU"], + validate: { + validator: function (value) { + // Only require SBU if the role is not "admin" + if (this.role !== "admin" && !value) { + return false; + } + return true; + }, + message: "SBU is required for users", + }, }, name: { type: String,