diff --git a/src/controllers/userController.js b/src/controllers/userController.js index 8c38d603..5836240d 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -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); + } +}; diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index add99d18..5305667e 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -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(); };