diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 85a666e3..21874994 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -327,6 +327,31 @@ exports.getAllTankersBookingdetails = async (req, reply) => { }; + +exports.getAllTankersaccepted = async (req, reply) => { + const limit = parseInt(req.query.limit) || 100; + const page = parseInt(req.query.page) || 1; + const startindex = (page - 1) * limit; + const supplierId = req.params.supplierId + try { + await Tankerbooking.find( { supplierId, orderStatus: ["accepted","rejected"] }) + .limit(limit) + .skip(startindex) + .exec() + .then((docs) => { + reply.send({ status_code: 200, data: docs, count: docs.length }); + }) + .catch((err) => { + console.log(err); + reply.send({ error: err }); + }); + } catch (err) { + throw boom.boomify(err); + } +}; + + + exports.addBores = async (req, reply) => { try { @@ -608,3 +633,4 @@ exports.connectstatus = async (req, reply) => { }; + diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index fa62fff1..56239206 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -675,6 +675,30 @@ module.exports = function (fastify, opts, next) { handler: tankersController.connectstatus, }); + + fastify.get("/api/alltankersaccepted/:supplierId", { + schema: { + tags: ["Supplier-Order"], + description: "This is for Get All connected and rejected for Suppliers", + summary: "This is for to Get All connected and rejected for suppliers", + params: { + type: "object", + properties: { + supplierId: { + type: "string", + description: "supplierId", + }, + }, + }, + + security: [ + { + basicAuth: [], + }, + ], + }, + handler: tankersController.getAllTankersaccepted, + }); next(); }