From 42d58b89a547de3b3b100f85a7ab93605c9dd55a Mon Sep 17 00:00:00 2001 From: Bhaskar Date: Tue, 2 Sep 2025 16:55:04 +0530 Subject: [PATCH] changes --- src/controllers/installationController.js | 32 +++++++++++------------ src/routes/installationRoute.js | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 7ca84932..9d923667 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -590,9 +590,9 @@ exports.getTeamMembers = async (request, reply) => { exports.getAllDepartments = async (request, reply) => { try { - const { officeName, city } = request.params; + const { officeName } = request.params; - if (!officeName || !city) { + if (!officeName ) { return reply.status(400).send({ simplydata: { error: true, @@ -607,28 +607,28 @@ exports.getAllDepartments = async (request, reply) => { "i" ); - // If city === "ALL" → no filter, else regex - const cityFilter = - city.toUpperCase() === "ALL" - ? {} - : { city: new RegExp(city.trim().replace(/\s+/g, "\\s*"), "i") }; + // // If city === "ALL" → no filter, else regex + // const cityFilter = + // city.toUpperCase() === "ALL" + // ? {} + // : { city: new RegExp(city.trim().replace(/\s+/g, "\\s*"), "i") }; // 1️⃣ Branch match (all branches for that officeName) const branchMatches = await Branch.find({ officeName: nameRegex, - ...cityFilter, + //...cityFilter, }).lean(); // 2️⃣ City (headOffice) match const cityMatches = await City.find({ officeName: nameRegex, - ...cityFilter, + //...cityFilter, }).lean(); // 3️⃣ Departments (all matching officeName + city filter) let departments = await Deparments.find({ officeName: nameRegex, - ...cityFilter, + // ...cityFilter, }).lean(); // Add contactPerson to departments @@ -642,12 +642,12 @@ exports.getAllDepartments = async (request, reply) => { // 🔹 Build response const responseData = [{ firstName: "Self" },{ reportingManager: "Self" }]; - branchMatches.forEach((br) => - responseData.push({ - officeType: "branch", - ...br, - }) - ); + // branchMatches.forEach((br) => + // responseData.push({ + // officeType: "branch", + // ...br, + // }) + // ); // cityMatches.forEach((ho) => // responseData.push({ diff --git a/src/routes/installationRoute.js b/src/routes/installationRoute.js index 9324b3ae..307fbc25 100644 --- a/src/routes/installationRoute.js +++ b/src/routes/installationRoute.js @@ -34,7 +34,7 @@ module.exports = function (fastify, opts, next) { handler: installationController.createTeamMember, }); -fastify.get("/api/getAllDepartments/:officeName/:city", { +fastify.get("/api/getAllDepartments/:officeName", { schema: { description: "Get full department details by department name", tags: ["Admin"], @@ -43,7 +43,7 @@ fastify.get("/api/getAllDepartments/:officeName/:city", { type: "object", properties: { officeName: { type: "string", }, - city: { type: "string", }, + // city: { type: "string", }, }, // required: ["departmentName"],