|
|
|
@ -99,28 +99,28 @@ exports.createTeamMember = async (request, reply) => {
|
|
|
|
|
|
|
|
|
|
exports.getTeamMembers = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { installationId } = request.params; // Get installationId from request params
|
|
|
|
|
const { departmentId } = request.params; // ✅ Get departmentId from request params
|
|
|
|
|
|
|
|
|
|
// Check if installation exists
|
|
|
|
|
const installation = await Install.findOne({ installationId });
|
|
|
|
|
// ✅ Find the department using departmentId
|
|
|
|
|
const department = await Deparments.findOne({ departmentId });
|
|
|
|
|
|
|
|
|
|
if (!installation) {
|
|
|
|
|
if (!department) {
|
|
|
|
|
return reply.status(404).send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: true,
|
|
|
|
|
message: "Installation not found",
|
|
|
|
|
message: "Department not found",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extract team members
|
|
|
|
|
const teamMembers = installation.team_member.team_member;
|
|
|
|
|
// ✅ Extract team members from department schema
|
|
|
|
|
const teamMembers = department.team_member.team_member;
|
|
|
|
|
|
|
|
|
|
return reply.send({
|
|
|
|
|
simplydata: {
|
|
|
|
|
error: false,
|
|
|
|
|
message: "Team members retrieved successfully",
|
|
|
|
|
teamMembers, // Return the list of team members
|
|
|
|
|
teamMembers, // ✅ Return the list of team members
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|