parent
636d286763
commit
9a4974a006
@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
const Supplier = require("../models/supplier");
|
||||||
|
const boom = require("boom");
|
||||||
|
const fastify = require("fastify")({
|
||||||
|
logger: true,
|
||||||
|
});
|
||||||
|
const { Tanker, Tankerbooking,Bore,GovtPipeLine } = require('../models/tankers')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.orderNow = async (req, reply) => {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const customerId = req.body.customerId;
|
||||||
|
const bookingId = req.params.bookingId;
|
||||||
|
const tankerName = req.body.tankerName;
|
||||||
|
const booking_info = await Tankerbooking.findOne({ bookingid: bookingId})
|
||||||
|
const action = req.body.action
|
||||||
|
const typeofwater = req.body.typeofwater
|
||||||
|
|
||||||
|
if(action === "accept"){
|
||||||
|
booking_info.orderStatus = "accepted"
|
||||||
|
booking_info.price = "500"
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
booking_info.orderStatus = "rejected"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const booking = await booking_info.save();
|
||||||
|
return booking;
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
throw boom.boomify(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,65 @@
|
|||||||
|
const fastify = require("fastify");
|
||||||
|
const supplierOrderController = require("../controllers/supplierOrderController");
|
||||||
|
const validationHandler = require("../handlers/supplierHandler");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = function (fastify, opts, next) {
|
||||||
|
|
||||||
|
fastify.route({
|
||||||
|
method: "POST",
|
||||||
|
url: "/api/ordernow/:bookingId",
|
||||||
|
schema: {
|
||||||
|
tags: ["Supplier-Order"],
|
||||||
|
description:"This is for giving booking data to supplier",
|
||||||
|
summary: "This is for giving booking data to supplier",
|
||||||
|
params: {
|
||||||
|
required: ["bookingId"],
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
bookingId: {
|
||||||
|
type: "string",
|
||||||
|
description: "bookingId",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
|
||||||
|
supplierName: {type: 'string'},
|
||||||
|
supplierId: { type: "string" },
|
||||||
|
customerId:{type:"string"},
|
||||||
|
capacity: { type: "string" },
|
||||||
|
customer_address: { type: "string" },
|
||||||
|
dateOfOrder: { type: "string"},
|
||||||
|
action:{type:"string"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
security: [
|
||||||
|
{
|
||||||
|
basicAuth: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
},
|
||||||
|
// preHandler: fastify.auth([fastify.authenticate]),
|
||||||
|
handler:supplierOrderController.orderNow,
|
||||||
|
// onResponse: (request, reply) => {
|
||||||
|
// validationHandler.sendPhoneVerificationCode(request, reply);
|
||||||
|
// },
|
||||||
|
//onResponse: validationHandler.sendPhoneVerificationCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue