added get request bookings for particular customer

master^2
Varun 3 months ago
parent 4bdd4bcd9d
commit 109bab2e2c

@ -1297,3 +1297,19 @@ exports.getuserOrders = async (req, reply) => {
} }
}; };
exports.getuserRequestbookings = async (req, reply) => {
try {
const { customerId } = req.params;
const orders = await RequestedBooking.find({ customerId }).sort({ createdAt: -1 }).lean();
return reply.send({
status_code: 200,
message: `Orders for customer ${customerId} fetched successfully`,
data: orders
});
} catch (err) {
throw boom.boomify(err);
}
};

@ -1152,5 +1152,32 @@ fastify.route({
fastify.route({
method: "GET",
url: "/api/getuserRequestbookings/:customerId",
schema: {
description: "To Get requestbookings of customer",
tags: ["User"],
summary: "This is for getting requestbookings of a customer",
params: {
type: "object",
properties: {
customerId: {
type: "string",
description: "Customer ID",
},
},
required: ["customerId"]
},
security: [
{
basicAuth: [],
},
],
},
// preHandler: fastify.auth([fastify.authenticate]),
handler: userController.getuserRequestbookings,
});
next(); next();
}; };

Loading…
Cancel
Save