|
|
|
@ -958,3 +958,59 @@ exports.getOfficeDetails = async (req, reply) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.adminEditTeamMember = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { departmentId, teamMemberId } = request.params;
|
|
|
|
|
const updateData = request.body;
|
|
|
|
|
|
|
|
|
|
// Find the installation
|
|
|
|
|
const installation = await Deparments.findOne({ departmentId });
|
|
|
|
|
|
|
|
|
|
if (!installation) {
|
|
|
|
|
return reply.status(404).send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: true,
|
|
|
|
|
message: "Installation not found",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the team member
|
|
|
|
|
let teamMember = installation.team_member.team_member.find(
|
|
|
|
|
(member) => member.teamMemberId === teamMemberId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!teamMember) {
|
|
|
|
|
return reply.status(404).send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: true,
|
|
|
|
|
message: "Team member not found",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update fields
|
|
|
|
|
Object.assign(teamMember, updateData);
|
|
|
|
|
|
|
|
|
|
// Save changes
|
|
|
|
|
await installation.markModified("team_member.team_member");
|
|
|
|
|
await installation.save();
|
|
|
|
|
|
|
|
|
|
return reply.send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: false,
|
|
|
|
|
message: "Team member updated successfully",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error("Error updating team member:", err);
|
|
|
|
|
reply.status(500).send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: true,
|
|
|
|
|
message: "Internal server error",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|