diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 16656628..cd674f82 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -633,3 +633,17 @@ exports.connectstatus = async (req, reply) => { + +//delete selected bookingid +exports.deleteBookingInfo = async (req, reply) => { + try { + var bookingid = req.params.bookingid; + + const booking = await Tankerbooking.findOneAndDelete({ bookingid:bookingid }); + + reply.send({ status_code: 200, data: booking}); + // return tank; + } catch (err) { + throw boom.boomify(err); + } +}; diff --git a/src/handlers/friendRequestHandler.js b/src/handlers/friendRequestHandler.js index b0cb7621..53455c1a 100644 --- a/src/handlers/friendRequestHandler.js +++ b/src/handlers/friendRequestHandler.js @@ -60,10 +60,10 @@ exports.friendRequest = async (request, reply) => { exports.friendRequestAccept = async (request, reply) => { try { //const {friendRequestId} = request.body; - const {supplierId} = request.body; + const {supplierId,customerId} = request.body; // Update the friend request status to 'accepted' // const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'accepted' }); - const friendRequest = await FriendRequest.findOneAndUpdate({supplierId}, { status: 'accepted' }); + const friendRequest = await FriendRequest.findOneAndUpdate({supplierId,customerId }, { status: 'accepted' }); console.log("friendRequest....---", friendRequest) @@ -82,10 +82,10 @@ exports.friendRequestAccept = async (request, reply) => { exports.friendRequestReject = async (request, reply) => { try { //const {friendRequestId} = request.body; - const {supplierId} = request.body; + const {supplierId, customerId} = request.body; // Update the friend request status to 'rejected' // const friendRequest = await FriendRequest.findByIdAndUpdate(friendRequestId, { status: 'rejected' }); - const friendRequest = await FriendRequest.findOneAndUpdate({supplierId}, { status: 'rejected' }); + const friendRequest = await FriendRequest.findOneAndUpdate({supplierId, customerId}, { status: 'rejected' }); console.log("friendRequest....---", friendRequest) diff --git a/src/routes/friendRequestRoute.js b/src/routes/friendRequestRoute.js index ec45ad4f..997223c4 100644 --- a/src/routes/friendRequestRoute.js +++ b/src/routes/friendRequestRoute.js @@ -32,7 +32,7 @@ module.exports = function (fastify, opts, next) { fastify.route({ method: "PUT", - url: "/api/friend-request/:id/accept", + url: "/api/friend-request/accept", schema: { tags: ["Friend-Request"], description: "This is for supplier accept the friend request", @@ -40,7 +40,8 @@ module.exports = function (fastify, opts, next) { body: { type: "object", properties: { - supplierId: { type: "string" } + supplierId: { type: "string" }, + customerId: { type: "string" } }, }, @@ -54,7 +55,7 @@ module.exports = function (fastify, opts, next) { }); fastify.route({ method: "PUT", - url: "/api/friend-request/:id/reject", + url: "/api/friend-request/reject", schema: { tags: ["Friend-Request"], description: "This is for supplier reject the friend request", @@ -64,7 +65,7 @@ module.exports = function (fastify, opts, next) { type: "object", properties: { supplierId: { type: "string" }, - + customerId: { type: "string" } }, }, security: [ diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index cd7d192e..83a995f2 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -701,6 +701,35 @@ module.exports = function (fastify, opts, next) { }, handler: tankersController.getAllTankersaccepted, }); + + + + fastify.route({ + method: "PUT", + url: "/api/deleteBookingInfo/:bookingid", + schema: { + tags: ["Supplier-Order"], + summary: "This is for delete Booking Info", + params: { + required: ["bookingid"], + type: "object", + properties: { + bookingid: { + type: "string", + description: "bookingid", + }, + }, + }, + security: [ + { + basicAuth: [], + }, + ], + }, + preHandler: fastify.auth([fastify.authenticate]), + handler: tankersController.deleteBookingInfo, + }); + next(); }