|
|
|
@ -699,19 +699,20 @@ exports.getZonebasedLocations = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const result = await City.aggregate([
|
|
|
|
|
{
|
|
|
|
|
$unwind: "$city" // Convert location array into separate documents
|
|
|
|
|
$project: {
|
|
|
|
|
city: { $trim: { input: "$city" } }, // Trim city field in DB
|
|
|
|
|
zone: 1 // Keep zone field
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
$match: {
|
|
|
|
|
city: { $regex: `^${city}$`, $options: "i" }, // Match city case-insensitively
|
|
|
|
|
city: { $regex: `^${city.trim()}$`, $options: "i" }, // Trim & case-insensitive
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
$group: {
|
|
|
|
|
_id: {
|
|
|
|
|
$toUpper: { $trim: { input: "$city" } } // Normalize city name
|
|
|
|
|
},
|
|
|
|
|
zones: { $addToSet: "$zone" } // Collect unique zones
|
|
|
|
|
_id: { $toUpper: "$city" }, // Normalize city name
|
|
|
|
|
zones: { $addToSet: "$zone" }, // Collect unique zones
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
@ -734,17 +735,18 @@ exports.getZonebasedLocations = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { city } = req.params;
|
|
|
|
|
|
|
|
|
|
if (!city) {
|
|
|
|
|
if (!city || city.trim() === "") {
|
|
|
|
|
return reply.status(400).send({ message: "City is required." });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const zones = await getZonesByCitys(city);
|
|
|
|
|
const zones = await getZonesByCitys(city.trim()); // Trim input
|
|
|
|
|
reply.send({ status_code: 200, data: zones });
|
|
|
|
|
} catch (err) {
|
|
|
|
|
reply.status(500).send({ message: err.message });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getDepartmentsByName = async (departmentName) => {
|
|
|
|
|
try {
|
|
|
|
|