|
|
@ -1645,6 +1645,38 @@ exports.getuserRequestbookingsforplansforsupplier = async (req, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getuserRequestbookingsforplansforcustomer = async (req, reply) => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const { customerId } = req.params;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!customerId) {
|
|
|
|
|
|
|
|
return reply.code(400).send({
|
|
|
|
|
|
|
|
status_code: 400,
|
|
|
|
|
|
|
|
message: "customerId is required",
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1) Find all bookings that include this supplier
|
|
|
|
|
|
|
|
const bookings = await RecurringRequestedBooking.find({
|
|
|
|
|
|
|
|
customerId: customerId,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.sort({ createdAt: -1 })
|
|
|
|
|
|
|
|
.lean();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2) For each booking, expose only this supplier's subdocument
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return reply.send({
|
|
|
|
|
|
|
|
status_code: 200,
|
|
|
|
|
|
|
|
message: `Orders for customer ${customerId} fetched successfully`,
|
|
|
|
|
|
|
|
data:bookings,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
console.error(err);
|
|
|
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
const mongoose = require('mongoose');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|