This is for fetching team members for a given installation

master^2
Bhaskar 1 month ago
parent 0f537efc1f
commit 6cb30b7dfe

@ -782,7 +782,19 @@ exports.assignTeamMemberToQuotation = async (request, reply) => {
}
};
exports.getInstallationTeamMembers = async (request, reply) => {
try {
const installationId = request.params.installationId;
const installation = await Install.findOne({ installationId });
if (!installation) {
return reply.status(404).send({ message: 'Installation not found' });
}
const teamMembers = installation.team_member.team_member;
reply.send({ teamMembers });
} catch (err) {
reply.status(500).send({ message: err.message });
}
};
exports.getQuotationsByInstallationId = async (request, reply) => {
try {
const { installationId } = request.params;

@ -88,7 +88,7 @@ fastify.get("/api/getAllDepartments/:officeName/:city", {
fastify.get("/api/getTeamMembers/:officeName/:city/:departmentId", {
schema: {
description: "Get all team members under a specific department",
tags: ["Installation"],
tags: ["Department"],
summary: "Get Team Members by Department ID",
params: {
type: "object",
@ -154,6 +154,24 @@ fastify.get("/api/getAllDepartments/:officeName/:city", {
},
handler: installationController.getQuotationsByInstallationAndTeamMember
});
fastify.route({
method: "GET",
url: "/api/installationsTeammembers/:installationId",
schema: {
tags: ["Installation"],
description: "This is for fetching team members for a given installation",
summary: "This is for fetching team members for a given installation",
params: {
type: "object",
properties: {
installationId: { type: "string" }
}
}
},
handler: installationController.getInstallationTeamMembers
});
fastify.post("/api/assignTeammember/:installationId", {
schema: {
description: "Assign a team member to an installation's quotation",

Loading…
Cancel
Save