diff --git a/src/controllers/tankersController.js b/src/controllers/tankersController.js index 20250f01..dbdf91f8 100644 --- a/src/controllers/tankersController.js +++ b/src/controllers/tankersController.js @@ -103,7 +103,8 @@ exports.deleteTankerInfo = async (req, reply) => { exports.tankerBooking = async (req, reply) => { try { - var customerId = req.params.customerId; + const customerId = req.params.customerId; + const tankerName = req.body.tankerName; var b_id = await generateBookingId() const date = new Date() const year = date.getFullYear() @@ -118,6 +119,7 @@ exports.tankerBooking = async (req, reply) => { else { bookingsData = { + tankerName:tankerName, customerId:customerId, bookingid : bookingId, typeofwater: req.body.typeofwater, @@ -134,6 +136,7 @@ exports.tankerBooking = async (req, reply) => { usertobeInserted = checkFormEncoding.tankersBookingData; console.log("thsi true url string"); tankersBookingData.customerId = customerId; + tankersBookingData.tankerName = tankerName; tankersBookingData.bookingid = bookingId; tankersBookingData.capacity = usertobeInserted.capacity; tankersBookingData.typeofwater = usertobeInserted.typeofwater; @@ -144,6 +147,7 @@ exports.tankerBooking = async (req, reply) => { } const booking_data = await tankersBookingData.save(); + reply.send({ status_code: 200, data: booking_data }); return booking_data; diff --git a/src/models/tankers.js b/src/models/tankers.js index 2d57de7a..e640d497 100644 --- a/src/models/tankers.js +++ b/src/models/tankers.js @@ -22,11 +22,13 @@ const tankersSchema = new mongoose.Schema({ const tankersbookingSchema = new mongoose.Schema({ customerId: { type: String, default: null }, + tankerName: { type: String, default: null }, bookingid: { type: String, default: null,unique: true }, dateOfOrder: { type: String, default: null }, typeofwater: { type: String, default: null }, capacity: { type: String, default: null }, address: { type: String, default: null }, + price: { type: String, default: "750" }, payment_status : { type: String, default: "due" }, //orderStatus: { type: String, default: "due" }, quantityDelivered: { type: String, default: null}, diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index 952256f5..ab4b99d7 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -185,10 +185,11 @@ module.exports = function (fastify, opts, next) { }, }, }, + body: { type: "object", properties: { - + tankerName: {type: 'string'}, typeofwater: { type: "string" }, capacity: { type: "string" }, address: { type: "string" },