const fastify = require("fastify"); const storeController = require('../controllers/storeController') const customJwtAuth = require('../customAuthJwt'); const fastifyJwt = require('fastify-jwt'); const userController = require('../controllers/userController'); module.exports = function (fastify, opts, next) { fastify.route({ method: 'POST', url: '/api/installSignup', schema: { tags: ['Install'], description: 'This is for creating a New Install Account', summary: 'This is for creating a New Install Account', body: { type: 'object', properties: { phone: { type: 'string' }, password: { type: 'string' }, emails: { type: 'array', maxItems: 2, items: { type: 'object', properties: { email: { type: 'string', default: null }, }, }, }, //name: { type: 'string' }, team: { type: 'string', default: null }, zone: { type: 'string', default: null }, designation: { type: 'string', default: null }, reportingManager: { type: 'string', default: null }, departmentName: { type: 'string', default: null }, manager: { type: 'string', default: null }, address: { type: 'string', default: null }, address1: { type: 'string', default: null }, address2: { type: 'string', default: null }, city: { type: 'string', default: null }, state: { type: 'string', default: null }, zip: { type: 'string', default: null }, country: { type: 'string', default: null }, notes: { type: 'string', default: null }, latitude: { type: 'number', default: 0.0 }, longitude: { type: 'number', default: 0.0 }, fcmId: { type: 'string', default: null }, alternativeNumber : { type: 'string', default: null }, firstName :{ type: 'string', default: null }, lastName : { type: 'string', default: null }, }, }, security: [ { basicAuth: [], }, ], }, handler: storeController.installSignUp, }); // fastify.post("/api/insatllLogin", { // schema: { // description: "This is for Login Install", // tags: ["Install"], // summary: "This is for Login Install", // body: { // type: "object", // required: ["phone", "password"], // properties: { // phone: { type: "string" }, // password: { type: "string" }, // }, // }, // }, // handler: storeController.installLogin, // }); // fastify.post("/api/installotplogin", { // schema: { // description: "This is for Login Otp Boy", // tags: ["Install"], // summary: "This is for Login Otp Boy", // body: { // type: "object", // required: ["phone"], // properties: { // phoneVerificationCode: { type: "string" }, // phone: { type: "string" }, // }, // }, // }, // handler: storeController.installationVerifyPhone, // }); fastify.post('/api/stores', { schema: { description: "Create a new store account", tags: ["Store-Data"], summary: "create a new store account.", body: { type: "object", // required: ["storename", "phone", "password"], properties: { storename: { type: "string" }, password: {type: "string"}, zone: { type: 'string', default: null }, designation: { type: 'string', default: null }, reportingManager: { type: 'string', default: null }, departmentName: { type: 'string', default: null }, phone: { type: "string", unique: true, trim: true }, contactPersonName: { type: "string" }, contactPersonPhone: { type: "string", unique: true, trim: true }, emails: { type: "string" }, description: { type: "string", default: null }, startingPrice: { type: "string", default: 0.0 }, profile: { type: "object", properties: { role: { type: "array", items: { type: "string" }, default: ["store"] }, firstName: { type: "string", default: null }, lastName: { type: "string", default: null }, contactNumber: { type: "string", default: null }, alternativeContactNumber: { type: "string", default: null }, store_address: { type: "string", default: null }, address1: { type: 'string', default: null }, address2: { type: 'string', default: null }, city: { type: "string", default: null }, state: { type: "string", default: null }, country: { type: "string", default: null }, zip: { type: "string", default: null }, }, }, longitude: { type: "number", default: 0.0 }, latitude: { type: "number", default: 0.0 }, fcmId: { type: "string", default: null }, }, }, security: [{ basicAuth: [] }], }, handler: storeController.addStore, }); fastify.post('/api/salesSignUp', { schema: { description: "This is for Create New Sales", tags: ["Sales-Data"], summary: "This is for Create New Sales.", body: { type: "object", properties: { username: { type: "string" }, designation: { type: 'string', default: null }, reportingManager: { type: 'string', default: null }, departmentName: { type: 'string', default: null }, zone: { type: 'string', default: null }, phone: { type: "string" }, password: { type: "string" }, emails: { type: "string" }, address: { type: "string", default: null }, profile: { type: "object", properties: { firstName: { type: "string" }, lastName: { type: "string" }, address: { type: "string" }, city: { type: 'string', default: null }, state: { type: 'string', default: null }, zip: { type: 'string', default: null }, country: { type: 'string', default: null }, address1: { type: 'string', default: null }, address2: { type: 'string', default: null }, }, required: ["firstName", "lastName"] } } }, security: [{ basicAuth: [] }], }, handler: storeController.addSales, }); fastify.get("/api/getallsales", { schema: { tags: ["Sales-Data"], description: "This is for Get all Sales Person Data", summary: "This is for to Get all Sales Person Data", security: [ { basicAuth: [], }, ], }, //preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getallsales, }); fastify.get("/api/getallstore", { schema: { tags: ["Sales-Data"], description: "This is for Get all Store Person Data", summary: "This is for to Get all Store Person Data", security: [ { basicAuth: [], }, ], }, //preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getallstore, }); fastify.delete("/api/deletesale/:salesId", { schema: { description: "Delete a Sales by salesId", tags: ["Sales-Data"], summary: "Delete a user by salesId", params: { type: "object", properties: { salesId: { type: "string" }, // Customer ID }, required: ["salesId"], }, response: { 200: { type: "object", properties: { success: { type: "boolean" }, message: { type: "string" }, } } } }, handler: storeController.deleteUserInfo, }); fastify.delete("/api/deleteStore/:storeId", { schema: { description: "Delete a Store by storeId", tags: ["Sales-Data"], summary: "Delete a Store by storeId", params: { type: "object", properties: { storeId: { type: "string" }, // Customer ID }, required: ["storeId"], }, response: { 200: { type: "object", properties: { success: { type: "boolean" }, message: { type: "string" }, } } } }, handler: storeController.deleteStoreInfo, }); fastify.put('/api/editSalesUser/:salesId', { schema: { description: "Edit Sales user details by Sales ID", tags: ["Sales-Data"], summary: "Edit sales user details.", params: { type: "object", properties: { salesId: { type: "string" }, }, required: ["salesId"], }, body: { type: "object", properties: { username: { type: "string" }, phone: { type: "string" }, zone: { type: 'string', default: null }, designation: { type: 'string', default: null }, reportingManager: { type: 'string', default: null }, departmentName: { type: 'string', default: null }, password: { type: "string" }, emails: { type: "string" }, address: { type: "string" }, profile: { type: "object", properties: { firstName: { type: "string" }, lastName: { type: "string" }, address: { type: "string" }, city: { type: 'string', default: null }, state: { type: 'string', default: null }, zip: { type: 'string', default: null }, country: { type: 'string', default: null }, address1: { type: 'string', default: null }, address2: { type: 'string', default: null }, }, } }, } }, handler: storeController.editSalesUser, }); fastify.put('/api/editStore/:storeId', { schema: { description: "Edit store details by Store ID", tags: ["Store-Data"], summary: "Edit store details.", params: { type: "object", properties: { storeId: { type: "string" }, }, required: ["storeId"], }, body: { type: "object", properties: { storename: { type: "string" }, phone: { type: "string" }, address: { type: "string" }, address1: { type: "string" }, address2: { type: "string" }, emails: { type: "string" }, zone: { type: 'string', default: null }, designation: { type: 'string', default: null }, reportingManager: { type: 'string', default: null }, departmentName: { type: 'string', default: null }, profile: { type: "object", properties: { firstName: { type: "string" }, lastName: { type: "string" }, contactNumber: { type: "string" }, alternativeContactNumber: { type: "string" }, store_address: { type: "string" }, city: { type: "string" }, state: { type: "string" }, country: { type: "string" }, zip: { type: "string" }, address1: { type: 'string', default: null }, address2: { type: 'string', default: null }, }, }, alternativeNumber: { type: "string" }, longitude: { type: "number" }, latitude: { type: "number" }, fcmId: { type: "string" }, description: { type: "string" }, startingPrice: { type: "string" }, contactPersonPhone: { type: "string" }, }, required: ["phone"], } }, handler: storeController.editStore, }); fastify.get("/api/getAllInstallers", { schema: { description: "Retrieve all users", tags: ["Install Management"], summary: "Get all users", // response: { // 200: { // type: "array", // items: { // type: "object", // properties: { // installationId: { type: "string" }, // phone: { type: "string" }, // password: { type: "string" }, // emails: { type: "array", items: { type: "object", properties: { email: { type: "string" } } } }, // team: { type: "string" }, // manager: { type: "string" }, // address: { type: "string" }, // address1: { type: "string" }, // address2: { type: "string" }, // city: { type: "string" }, // state: { type: "string" }, // zip: { type: "string" }, // country: { type: "string" }, // notes: { type: "string" }, // latitude: { type: "number" }, // longitude: { type: "number" }, // fcmId: { type: "string" }, // alternativeNumber: { type: "string" }, // firstName: { type: "string" }, // lastName: { type: "string" }, // }, // }, // }, // }, }, handler: storeController.getAllUsers, }); fastify.delete("/api/deleteInstaller/:installationId", { schema: { description: "Delete a user by installationId", tags: ["Install Management"], summary: "Delete user", params: { type: "object", properties: { installationId: { type: "string" }, }, required: ["installationId"], }, response: { 200: { type: "object", properties: { message: { type: "string" }, }, }, }, }, handler: storeController.deleteUserByInstallationId, }); fastify.put("/api/updaeInstaller/:installationId", { schema: { description: "Update installer details by installationId", tags: ["Install Management"], summary: "Update installer details by installationId", params: { type: "object", properties: { installationId: { type: "string" }, }, required: ["installationId"], }, body: { type: "object", properties: { phone: { type: "string" }, password: { type: "string" }, emails: { type: "array", items: { type: "object", properties: { email: { type: "string" } } } }, team: { type: "string" }, zone: { type: 'string', default: null }, designation: { type: 'string', default: null }, reportingManager: { type: 'string', default: null }, departmentName: { type: 'string', default: null }, manager: { type: "string" }, address: { type: "string" }, address1: { type: "string" }, address2: { type: "string" }, city: { type: "string" }, state: { type: "string" }, zip: { type: "string" }, country: { type: "string" }, notes: { type: "string" }, latitude: { type: "number" }, longitude: { type: "number" }, fcmId: { type: "string" }, alternativeNumber: { type: "string" }, firstName: { type: "string" }, lastName: { type: "string" }, }, }, response: { 200: { type: "object", properties: { message: { type: "string" }, }, }, }, }, handler: storeController.updateUserByInstallationId, }); fastify.get("/api/getusersofParticularInstaller", { schema: { tags: ["Install"], description: "This is to Get users of Installer", summary: "This is to Get users of Installer", querystring: { InstallerId: {type: 'string'} }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getusersofParticularInstaller, }); fastify.post("/api/createwaterlevelSensor/:storeId", { schema: { description: "This is for creating waterlevel Sensor", tags: ["Store-Data"], summary: "This is for creating waterlevel Sensor", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, type: { type: "string" }, indate: { type: "string" }, hardwareId_company: { type: "string" } }, }, }, handler: storeController.createwaterlevelSensor, }) fastify.put("/api/editwaterlevelSensor/:storeId", { schema: { description: "This is for editing a water level sensor", tags: ["Store-Data"], summary: "This is for editing a water level sensor", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, type: { type: "string" }, indate: { type: "string" }, hardwareId_company: { type: "string" } }, }, }, handler: storeController.editWaterLevelSensor, }); fastify.delete("/api/deletewaterlevelSensor/:storeId", { schema: { description: "This is for deleting a water level sensor", tags: ["Store-Data"], summary: "This is for deleting a water level sensor", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, }, }, }, handler: storeController.deleteWaterLevelSensor, }); fastify.get("/api/getHardware/:storeId", { schema: { tags: ["Store-Data"], description: "This is to Get Waterlevel sensor Data", summary: "This is to Get Waterlevel sensor Data", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getHardware, }); fastify.post("/api/qccheckwaterlevelSensor/:hardwareId", { schema: { description: "This is for checking waterlevel Sensor", tags: ["Store-Data"], summary: "This is for checking waterlevel Sensor", params: { required: ["hardwareId"], type: "object", properties: { hardwareId: { type: "string", description: "hardwareId", }, }, }, body: { type: "object", properties: { qccheck: { type: "string" }, qccheckdate: { type: "string" }, qcby: { type: "string" }, comment: { type: "string" }, outforrepairdate: { type: "string" }, sendto: { type: "string" }, repairfeedback: { type: "string" }, }, }, }, handler: storeController.qccheckwaterlevelSensor, }) fastify.put("/api/getHardwareqc/:storeId", { schema: { tags: ["Store-Data"], description: "This is to Get Quality Check Details Of Waterlevel Sensor", summary: "This is to Get Quality Details Of Waterlevel Sensor", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getHardwareqc, }); fastify.post("/api/installwaterlevelSensor/:storeId", { schema: { description: "This is for installing waterlevel Sensor", tags: ["Store-Data"], summary: "This is for installing waterlevel Sensor", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, dateofinstallation: { type: "string" }, customerId: { type: "string" }, installedby: { type: "string" } }, }, }, handler: storeController.installwaterlevelSensor, }) fastify.post("/api/addSlave/:hardwareId", { schema: { description: "This is for adding slaves to waterlevel Sensor(Slave)", tags: ["Store-Data"], summary: "This is for adding slaves to waterlevel Sensor(Slave)", params: { required: ["hardwareId"], type: "object", properties: { hardwareId: { type: "string", description: "Main hardware ID", }, }, }, body: { type: "object", properties: { tankhardwareId: { type: "string" }, type: { type: "string" }, indate: { type: "string" }, hardwareId_company: { type: "string" } }, }, }, handler: storeController.addSlave, }); fastify.put("/api/editSlave/:hardwareId", { schema: { description: "This is for editing a slave of a water level sensor", tags: ["Store-Data"], summary: "This is for editing a slave of a water level sensor", params: { required: ["hardwareId"], type: "object", properties: { hardwareId: { type: "string", description: "Main hardware ID", }, }, }, body: { type: "object", properties: { tankhardwareId: { type: "string" }, type: { type: "string" }, indate: { type: "string" }, hardwareId_company: { type: "string" }, qccheck: { type: "string", default: null }, qccheckdate: { type: "string", default: null }, qcby: { type: "string", default: null }, comment: { type: "string", default: "0" }, outforrepairdate: { type: "string", default: "0" }, sendto: { type: "string", default: null }, repairfeedback: { type: "string", default: "0" }, dateofinstallation: { type: "string", default: null }, installedby: { type: "string", default: "0" }, customerId: { type: "string", default: "0" }, comments: { type: "string", default: "0" }, }, }, }, handler: storeController.editSlave, }); fastify.delete("/api/deleteSlave/:hardwareId", { schema: { description: "This is for deleting a slave of a water level sensor", tags: ["Store-Data"], summary: "This is for deleting a slave of a water level sensor", params: { required: ["hardwareId"], type: "object", properties: { hardwareId: { type: "string", description: "Main hardware ID", }, }, }, body: { type: "object", properties: { tankhardwareId: { type: "string" }, }, }, }, handler: storeController.deleteSlave, }); fastify.post("/api/qccheckwaterlevelslaveSensor/:storeId", { schema: { description: "This is for checking slaves (Slave)", tags: ["Store-Data"], summary: "This is for checking slaves (Slave)", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "Store ID", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, tankhardwareId: { type: "string" }, qccheck: { type: "string" }, qccheckdate: { type: "string" }, qcby: { type: "string" }, comment: { type: "string" }, outforrepairdate: { type: "string" }, sendto: { type: "string" }, repairfeedback: { type: "string" }, }, }, }, handler: storeController.qccheckwaterlevelSensorSlave, }); fastify.put("/api/getHardwareqcslave/:storeId", { schema: { tags: ["Store-Data"], description: "This is to Get Quality Check Data Of Slave (Slave)", summary: "This is to Get Quality Check Data Of Slave (Slave)", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "Store ID", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, tankhardwareId: { type: "string" }, // Optional field for tank hardware }, }, security: [ { basicAuth: [], }, ], }, handler: storeController.getHardwareqcslave, }); fastify.post("/api/installwaterlevelSensorSlave/:storeId", { schema: { description: "This is for installing Slaves (Slave)", tags: ["Store-Data"], summary: "This is for installing Slaves (Slave)", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "Store ID", }, }, }, body: { type: "object", properties: { hardwareId: { type: "string" }, tankhardwareId: { type: "string" }, // Add tankhardwareId in body dateofinstallation: { type: "string" }, customerId: { type: "string" }, installedby: { type: "string" } }, }, }, handler: storeController.installwaterlevelSensorSlave, }); fastify.post("/api/createmotorswitchSensor/:storeId", { schema: { description: "This is for creating motor switch", tags: ["Store-Data"], summary: "This is for creating motor switch", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { motorId: { type: "string" }, type: { type: "string" }, indate: { type: "string" }, }, }, }, handler: storeController.createmotorswitchSensor, }) fastify.get("/api/getHardwaremotorswitch/:storeId", { schema: { tags: ["Store-Data"], description: "This is to Get Motor Switches", summary: "This is to Get Motor Switches", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getHardwaremotorswitch, }); fastify.post("/api/qccheckpumpswitch/:motorId", { schema: { description: "This is for checking Motor Switch", tags: ["Store-Data"], summary: "This is for checking Motor Switch", params: { required: ["motorId"], type: "object", properties: { motorId: { type: "string", description: "motorId", }, }, }, body: { type: "object", properties: { qccheck: { type: "string" }, qccheckdate: { type: "string" }, qcby: { type: "string" }, comment: { type: "string" }, outforrepairdate: { type: "string" }, sendto: { type: "string" }, repairfeedback: { type: "string" }, }, }, }, handler: storeController.qccheckmotorswitch, }) fastify.put("/api/getpumpswitchqc/:storeId", { schema: { tags: ["Store-Data"], description: "This is to Get Quality Check Details Of Motor Switch", summary: "This is to Get Quality Details Of Motor Switch", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { motorId: { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getpumpswitchqc, }); fastify.post("/api/installmotorswitch/:storeId", { schema: { description: "This is for installing Motor Switch", tags: ["Store-Data"], summary: "This is for installing Motor Switch", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { motorId: { type: "string" }, dateofinstallation: { type: "string" }, customerId: { type: "string" }, installedby: { type: "string" } }, }, }, handler: storeController.installmotorswitch, }) fastify.post("/api/createwaterlevelSensorintime/:storeId", { schema: { description: "This is for creating Sensors at in time", tags: ["Store-Data"], summary: "This is for creating Sensors at in time", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, body: { type: "object", properties: { batchno: { type: "string" }, model:{type:"string"}, type:{type:"string"}, quantity: { type: "string" }, indate: { type: "string" }, hardwareId_company: { type: "string" } }, }, }, handler: storeController.createSensor, }) fastify.get("/api/getbatchnumbers/:storeId/:type", { schema: { tags: ["Store-Data"], description: "This is to Get batch numbers", summary: "This is to Get batch numbers", params: { type: "object", properties: { storeId: { type: "string", description: "storeId", }, type: { type: "string", description: "type", }, }, required: ["storeId", "type"], }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getbatchnumbers, }); fastify.get("/api/getiots/:storeId/:type", { schema: { tags: ["Store-Data"], description: "This is to Get iots of particular store", summary: "This is to iots of particular store", params: { type: "object", properties: { storeId: { type: "string", description: "storeId", }, type: { type: "string", description: "type", }, }, required: ["storeId", "type"], }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getiots, }); fastify.post("/api/createquotationforSensor/:installationId", { schema: { description: "This is for create quotation for sensors", tags: ["Install"], summary: "This is for create quotation for sensors", params: { required: ["installationId"], type: "object", properties: { installationId: { type: "string", description: "installationId", }, }, }, body: { type: "object", properties: { customerId: { type: "string" }, masters: { type: "string" }, slaves: { type: "string" }, sensors: { type: "string" }, motor_switches: { type: "string" }, electricals: { type: "array", maxItems: 2500, items: { type: "object", properties: { type: { type: "string", default: null }, wire: { type: "string", default: null }, switch: { type: "string", default: null }, text: { type: "string", default: null }, }, }, }, }, }, }, handler: storeController.createquotationforSensor, }); fastify.post("/api/editQuotationForSensor/:quatationId", { schema: { description: "This is for edit quotation for sensors", tags: ["Install"], summary: "This is for edit quotation for sensors", params: { required: ["quatationId"], type: "object", properties: { quatationId: { type: "string", description: "quatationId", }, }, }, body: { type: "object", properties: { masters: { type: "string" }, slaves: { type: "string" }, sensors: { type: "string" }, motor_switches: { type: "string" }, electricals: { type: "array", maxItems: 2500, items: { type: "object", properties: { type: { type: "string", default: null }, wire: { type: "string", default: null }, switch: { type: "string", default: null }, text: { type: "string", default: null }, }, }, }, }, }, }, handler: storeController.editQuotationForSensor, }); fastify.post("/api/getquotationofinstalleranduser/:installationId", { schema: { tags: ["Install"], description: "This is to Get Quotations for installer and particular user", summary: "This is to Get Quotations for installer and particular user", params: { required: ["installationId"], type: "object", properties: { installationId: { type: "string", description: "installationId", }, }, }, body: { type: "object", properties: { customerId: { type: "string" }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getquotationofinstalleranduser, }); fastify.get("/api/getallquotationdata", { schema: { tags: ["Install"], description: "This is for Get All Quotation Data", summary: "This is for to Get All Quotation Data", security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getallquotationdata, }); fastify.post("/api/sendBackQuotationforSensor/:quotationId", { schema: { description: "This is for sending back the quotation for sensors", tags: ["Install"], summary: "Send back quotation for sensors", params: { type: "object", properties: { quotationId: { type: "string", description: "quotationId", }, }, }, body: { type: "object", properties: { masters_quantity_price: { type: "string" }, masters_total_price: { type: "string" }, slaves_quantity_price: { type: "string" }, slaves_total_price: { type: "string" }, motor_switches_quantity_price: { type: "string" }, motor_switches_total_price: { type: "string" }, electricals_quantity_price: { type: "string" }, electricals_total_price: { type: "string" }, master_type_quantity_price: { type: "string" }, master_type_total_price: { type: "string" }, sensor_type_quantity_price: { type: "string" }, sensor_type_total_price: { type: "string" }, switch_type_quantity_price: { type: "string" }, switch_type_total_price: { type: "string" }, quotation_total_price: { type: "string" }, }, }, }, handler: storeController.saveQuotationData, }); fastify.get("/api/getSingleQuotationData/:quotationId", { schema: { tags: ["Install"], description: "This is for Get Single Quotation Data", summary: "This is to Get Single Quotation Data", params: { type: "object", properties: { quotationId: { type: "string", description: "quotationId", }, }, }, security: [ { basicAuth: [], }, ], }, handler: storeController.getSinleQuotationData, }); fastify.post("/api/cart/hardwareItem", { schema: { description: "To add items to the Hardwarecart", tags: ["Cart"], summary: "Add item to Hardwarecart", body: { type: "object", properties: { productId: { type: "string", description: "Unique identifier for the product" }, productName: { type: "string", description: "Name of the product" }, description: { type: "string", description: "Product description", default: null }, GST: { type: "number", description: "GST applied to the product", minimum: 0 }, unitPrice: { type: "number", description: "Unit price of the product", minimum: 0 }, quantity: { type: "integer", description: "Quantity of the product", minimum: 1 }, totalAmount: { type: "number", description: "Total amount before GST", minimum: 0 }, serialId: { type: "string", description: "Serial identifier for the cart item", default: null } }, //required: ["productId", "productName", "GST", "unitPrice", "quantity", "totalAmount"] }, }, handler: storeController.addToCartHardwareItems }); fastify.post("/api/cart/installationService", { schema: { description: "To add items to the Installation Service", tags: ["Cart"], summary: "Add item to Installation Service", body: { type: "object", properties: { installationId: { type: "string" }, productId: { type: "string"}, productName: { type: "string" }, description: { type: "string" }, GST: { type: "number", description: "GST applied to the product", minimum: 0 }, unitPrice: { type: "number", description: "Unit price of the product", minimum: 0 }, quantity: { type: "integer", description: "Quantity of the product", minimum: 1 }, totalAmount: { type: "number", description: "Total amount before GST", minimum: 0 }, serialId: { type: "string", description: "Serial identifier for the cart item", default: null } }, //required: ["productId", "productName", "GST", "unitPrice", "quantity", "totalAmount"] }, }, handler: storeController.addToCartService }); next(); };