|
|
|
|
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"},
|
|
|
|
|
price :{type:"string"},
|
|
|
|
|
delivery_agent :{type:"string"},
|
|
|
|
|
agent_mobile :{type:"string"},
|
|
|
|
|
agent_alternative_mobile :{type:"string"},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
security: [
|
|
|
|
|
{
|
|
|
|
|
basicAuth: [],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
// preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
|
handler:supplierOrderController.orderNow,
|
|
|
|
|
// onResponse: (request, reply) => {
|
|
|
|
|
// validationHandler.sendPhoneVerificationCode(request, reply);
|
|
|
|
|
// },
|
|
|
|
|
//onResponse: validationHandler.sendPhoneVerificationCode,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
|
method: "POST",
|
|
|
|
|
url: "/api/addDeliveryboys/:supplierId",
|
|
|
|
|
schema: {
|
|
|
|
|
tags: ["Supplier-Data"],
|
|
|
|
|
description: "This is for adding delivery boys",
|
|
|
|
|
summary: "This is for adding delivery boys",
|
|
|
|
|
params: {
|
|
|
|
|
required: ["supplierId"],
|
|
|
|
|
type: "object",
|
|
|
|
|
properties: {
|
|
|
|
|
supplierId: {
|
|
|
|
|
type: "string",
|
|
|
|
|
description: "supplierId",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
body: {
|
|
|
|
|
type: "object",
|
|
|
|
|
properties: {
|
|
|
|
|
Name: { type: "string" },
|
|
|
|
|
phone: { type: "string" },
|
|
|
|
|
alternativeContactNumber : { type : "string" },
|
|
|
|
|
address: { type: "string", default: null },
|
|
|
|
|
city: { type: "string", default: null },
|
|
|
|
|
state: { type: "string", default: null },
|
|
|
|
|
zip: { type: "string", default: null },
|
|
|
|
|
status: { type: "string" },
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
security: [
|
|
|
|
|
{
|
|
|
|
|
basicAuth: [],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
preHandler: [
|
|
|
|
|
//validationHandler.fieldCheck,
|
|
|
|
|
//validationHandler.verifySupplier,
|
|
|
|
|
// validationHandler.validatePhoneFormat,
|
|
|
|
|
//validationHandler.validateEmailFormat,
|
|
|
|
|
],
|
|
|
|
|
handler: supplierOrderController.addDeliveryboy,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
fastify.get("/api/getActiveDeliveryboys/:supplierId", {
|
|
|
|
|
schema: {
|
|
|
|
|
tags: ["Supplier-Data"],
|
|
|
|
|
description: "This is for Get avtive delivery boys Data",
|
|
|
|
|
summary: "This is for to Get avtive delivery boys Data",
|
|
|
|
|
params: {
|
|
|
|
|
required: ["supplierId"],
|
|
|
|
|
type: "object",
|
|
|
|
|
properties: {
|
|
|
|
|
supplierId: {
|
|
|
|
|
type: "string",
|
|
|
|
|
description: "supplierId",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
security: [
|
|
|
|
|
{
|
|
|
|
|
basicAuth: [],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
|
handler: supplierOrderController.getactiveDeliveryboys,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.route({
|
|
|
|
|
method: "POST",
|
|
|
|
|
url: "/api/phoneverify",
|
|
|
|
|
schema: {
|
|
|
|
|
tags: ["Supplier-Data"],
|
|
|
|
|
description: "This is for verify supplier Phone",
|
|
|
|
|
summary: "This is to Verify supplier Phone.",
|
|
|
|
|
body: {
|
|
|
|
|
type: "object",
|
|
|
|
|
required: ["phone"],
|
|
|
|
|
properties: {
|
|
|
|
|
phoneVerificationCode: { type: "string" },
|
|
|
|
|
phone: { type: "string" },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
security: [
|
|
|
|
|
{
|
|
|
|
|
basicAuth: [],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
// preHandler: fastify.auth([fastify.authenticate]),
|
|
|
|
|
handler: supplierOrderController.verifyPhone,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|