Bhaskar 3 weeks ago
commit a2514a9f58

@ -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');

@ -1221,6 +1221,27 @@ fastify.route({
}); });
fastify.route({
method: "GET",
url: "/api/getuserRequestbookingsforplansforcustomer/:customerId",
schema: {
description: "Fetch plans of the customer",
tags: ["Supplier"],
summary: "Fetch plans of the customer",
params: {
type: "object",
properties: {
customerId: { type: "string", description: "customerId" },
},
required: ["customerId"],
},
security: [{ basicAuth: [] }],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: userController.getuserRequestbookingsforplansforcustomer,
});
fastify.route({ fastify.route({
method: "POST", method: "POST",

Loading…
Cancel
Save