const fastify = require("fastify"); const storeController = require('../controllers/storeController') const customJwtAuth = require('../customAuthJwt'); const fastifyJwt = require('fastify-jwt'); 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 }, 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: "This is for Create New Store", tags: ["Store-Data"], summary: "This is for Create New Store.", body: { type: "object", required: ["storename", "phone", "password"], properties: { storename: { type: "string" }, phone: { type: "string" }, alternativeContactNumber: { type: "string" }, password: { type: "string" }, emails: { type: "string" }, office_address: { type: "string", default: null }, city: { type: "string", default: null }, state: { type: "string", default: null }, zip: { type: "string", default: null }, country: { type: "string", default: null }, latitude: { type: 'number', default: 0.0 }, longitude: { type: 'number', default: 0.0 }, fcmId: { type: "string", default: null }, description: { type: "string", default: null }, }, }, security: [{ basicAuth: [] }], }, handler: storeController.addStore, }); 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", { schema: { tags: ["Store-Data"], description: "This is to Get batch numbers", summary: "This is to Get batch numbers", params: { required: ["storeId"], type: "object", properties: { storeId: { type: "string", description: "storeId", }, }, }, security: [ { basicAuth: [], }, ], }, // preHandler: fastify.auth([fastify.authenticate]), handler: storeController.getbatchnumbers, }); 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" }, motor_switches: { type: "string" }, electricals: { type: "string" }, master_type: { type: "string" }, sensor_type: { type: "string" }, switch_type: { type: "string" }, }, }, }, handler: storeController.createquotationforSensor, }) 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(); };