|
|
@ -1371,23 +1371,24 @@ exports.getOffices = async (req, reply) => {
|
|
|
|
const filter = {};
|
|
|
|
const filter = {};
|
|
|
|
|
|
|
|
|
|
|
|
if (officeName && officeName !== 'ALL') {
|
|
|
|
if (officeName && officeName !== 'ALL') {
|
|
|
|
// support multiple office names as comma-separated
|
|
|
|
|
|
|
|
const officeNames = officeName.split(',').map(name => name.trim());
|
|
|
|
const officeNames = officeName.split(',').map(name => name.trim());
|
|
|
|
filter.officeName = { $in: officeNames };
|
|
|
|
filter.officeName = { $in: officeNames };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (city && city !== 'ALL') {
|
|
|
|
if (city && city !== 'ALL') {
|
|
|
|
// support multiple cities as comma-separated
|
|
|
|
|
|
|
|
const cities = city.split(',').map(c => c.trim());
|
|
|
|
const cities = city.split(',').map(c => c.trim());
|
|
|
|
filter.city = { $in: cities };
|
|
|
|
filter.city = { $in: cities };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const offices = await Deparments.find(filter).lean();
|
|
|
|
const offices = await Deparments.find(filter).lean();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Extract only department names and remove duplicates
|
|
|
|
|
|
|
|
const departmentNames = [...new Set(offices.map(o => o.departmentName))];
|
|
|
|
|
|
|
|
|
|
|
|
reply.send({
|
|
|
|
reply.send({
|
|
|
|
status_code: 200,
|
|
|
|
status_code: 200,
|
|
|
|
message: "Fetched successfully",
|
|
|
|
message: "Fetched successfully",
|
|
|
|
data: offices,
|
|
|
|
data: departmentNames,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
@ -1401,6 +1402,8 @@ exports.getOffices = async (req, reply) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// API route handler
|
|
|
|
// API route handler
|
|
|
|
exports.getDepartmentsByCity = async (req, reply) => {
|
|
|
|
exports.getDepartmentsByCity = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|