|
|
@ -460,32 +460,32 @@ exports.getAllCompanys = async (req, reply) => {
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.getAllOffices = async (req, reply) => {
|
|
|
|
exports.getAllOffices = async (req, reply) => {
|
|
|
|
// try {
|
|
|
|
try {
|
|
|
|
// const { officeName } = req.query;
|
|
|
|
const { officeName } = req.query;
|
|
|
|
|
|
|
|
|
|
|
|
// let filter = {};
|
|
|
|
let filter = {};
|
|
|
|
|
|
|
|
|
|
|
|
// if (officeName && officeName.toUpperCase() !== "ALL") {
|
|
|
|
if (officeName && officeName.toUpperCase() !== "ALL") {
|
|
|
|
// // Partial and case-insensitive match
|
|
|
|
// Partial and case-insensitive match
|
|
|
|
// filter.officeName = { $regex: new RegExp(officeName, "i") };
|
|
|
|
filter.officeName = { $regex: new RegExp(officeName, "i") };
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// const offices = await Branch.find(filter).lean();
|
|
|
|
const offices = await Branch.find(filter).lean();
|
|
|
|
|
|
|
|
|
|
|
|
// return reply.code(200).send({
|
|
|
|
return reply.code(200).send({
|
|
|
|
// status_code: 200,
|
|
|
|
status_code: 200,
|
|
|
|
// message: "Fetched successfully",
|
|
|
|
message: "Fetched successfully",
|
|
|
|
// data: offices
|
|
|
|
data: offices
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
// } catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
// console.error("Error fetching offices:", error);
|
|
|
|
console.error("Error fetching offices:", error);
|
|
|
|
// return reply.code(500).send({
|
|
|
|
return reply.code(500).send({
|
|
|
|
// status_code: 500,
|
|
|
|
status_code: 500,
|
|
|
|
// message: "Internal server error"
|
|
|
|
message: "Internal server error"
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// exports.getCityOffices = async (req, reply) => {
|
|
|
|
// exports.getCityOffices = async (req, reply) => {
|
|
|
|