|
|
@ -1128,14 +1128,14 @@ const getDepartmentsByName = async (officeName, city, departmentName) => {
|
|
|
|
.select("departmentName -_id")
|
|
|
|
.select("departmentName -_id")
|
|
|
|
.lean();
|
|
|
|
.lean();
|
|
|
|
|
|
|
|
|
|
|
|
return result.map(doc => doc.departmentName);
|
|
|
|
// Remove duplicate department names
|
|
|
|
|
|
|
|
return [...new Set(result.map(doc => doc.departmentName))];
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error("Error fetching departments by city:", error);
|
|
|
|
console.error("Error fetching departments by city:", error);
|
|
|
|
throw new Error("Error fetching departments by city.");
|
|
|
|
throw new Error("Error fetching departments by city.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// API route handler
|
|
|
|
// API route handler
|
|
|
|
exports.getDepartmentsByCity = async (req, reply) => {
|
|
|
|
exports.getDepartmentsByCity = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1156,3 +1156,4 @@ exports.getDepartmentsByCity = async (req, reply) => {
|
|
|
|
reply.status(500).send({ message: error.message });
|
|
|
|
reply.status(500).send({ message: error.message });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|