ADD tank and add bore changes

master
Bhaskar 1 year ago
parent bfe7fda84b
commit 1506c839a2

@ -388,13 +388,14 @@ exports.addBores = async (req, reply) => {
try { try {
var InstallerId = req.params.InstallerId; var customerId = req.params.customerId;
//console.log(customerId); //console.log(customerId);
//const username = loginObject.user.username; //const username = loginObject.user.username;
boresData = { boresData = {
InstallerId:InstallerId, // InstallerId:InstallerId,
customerId:req.body.customerId, // customerId:req.body.customerId,
customerId:customerId,
boreName: req.body.boreName, boreName: req.body.boreName,
capacity: req.body.capacity, capacity: req.body.capacity,
typeofwater: req.body.typeofwater, typeofwater: req.body.typeofwater,
@ -416,7 +417,7 @@ exports.addBores = async (req, reply) => {
usertobeInserted = checkFormEncoding.bores; usertobeInserted = checkFormEncoding.bores;
console.log("thsi true url string"); console.log("thsi true url string");
bores.InstallerId = usertobeInserted.InstallerId // bores.InstallerId = usertobeInserted.InstallerId
bores.customerId = usertobeInserted.customerId bores.customerId = usertobeInserted.customerId
bores.boreName = usertobeInserted.boreName; bores.boreName = usertobeInserted.boreName;

@ -88,11 +88,10 @@ async function deleteOldRecords() {
exports.addTanks = async (req, reply) => { exports.addTanks = async (req, reply) => {
try { try {
const InstallerId = req.params.InstallerId; const customerId = req.params.customerId;
const { customerId,hardwareId, tankhardwareId,tankName,tankLocation } = req.body; const { hardwareId, tankhardwareId,tankName,tankLocation } = req.body;
// Check if the combination of hardwareId and tankhardwareId already exists
const existingTank = await Tank.findOne({ const existingTank = await Tank.findOne({
customerId: customerId, customerId: customerId,
hardwareId: hardwareId, hardwareId: hardwareId,
@ -106,7 +105,7 @@ exports.addTanks = async (req, reply) => {
} }
const tankData = { const tankData = {
InstallerId:InstallerId, // InstallerId:InstallerId,
customerId: customerId, customerId: customerId,
hardwareId: hardwareId, hardwareId: hardwareId,
tankhardwareId: tankhardwareId, tankhardwareId: tankhardwareId,

@ -269,18 +269,18 @@ module.exports = function (fastify, opts, next) {
fastify.route({ fastify.route({
method: "POST", method: "POST",
url: "/api/addBores/:InstallerId", url: "/api/addBores/:customerId",
schema: { schema: {
tags: ["Install"], tags: ["Install"],
description: "This is to cretae New Bore", description: "This is to cretae New Bore",
summary: "This is to Create New Bore.", summary: "This is to Create New Bore.",
params: { params: {
required: ["InstallerId"], // required: ["InstallerId"],
type: "object", type: "object",
properties: { properties: {
InstallerId: { customerId: {
type: "string", type: "string",
description: "InstallerId", description: "customerId",
}, },
}, },
}, },
@ -288,7 +288,7 @@ module.exports = function (fastify, opts, next) {
type: "object", type: "object",
properties: { properties: {
boreName: { type: "string" }, boreName: { type: "string" },
customerId: { type: "string" }, // customerId: { type: "string" },
capacity: { type: "string" }, capacity: { type: "string" },
typeofwater: { type: "string" }, typeofwater: { type: "string" },
description: { type: "string" }, description: { type: "string" },

@ -6,18 +6,18 @@ module.exports = function (fastify, opts, next) {
fastify.route({ fastify.route({
method: "POST", method: "POST",
url: "/api/addTanks/:InstallerId", url: "/api/addTanks/:customerId",
schema: { schema: {
tags: ["Install"], tags: ["Install"],
description: "This is for cretae New Tank", description: "This is for cretae New Tank",
summary: "This is for Create New Tank.", summary: "This is for Create New Tank.",
params: { params: {
required: ["InstallerId"], // required: ["InstallerId"],
type: "object", type: "object",
properties: { properties: {
InstallerId: { customerId: {
type: "string", type: "string",
description: "InstallerId", description: "customerId",
}, },
}, },
}, },
@ -29,7 +29,7 @@ module.exports = function (fastify, opts, next) {
tankName: { type: "string" }, tankName: { type: "string" },
blockName: { type: "string"}, blockName: { type: "string"},
capacity: { type: "string" }, capacity: { type: "string" },
customerId: { type: "string" }, // customerId: { type: "string" },
typeOfWater: { type: "string" }, typeOfWater: { type: "string" },
waterCapacityPerCm:{ type: "string" }, waterCapacityPerCm:{ type: "string" },
tankLocation: { type: "string" }, tankLocation: { type: "string" },
@ -43,7 +43,7 @@ module.exports = function (fastify, opts, next) {
], ],
}, },
// preHandler: fastify.auth([fastify.authenticate]), preHandler: fastify.auth([fastify.authenticate]),
handler: tanksController.addTanks, handler: tanksController.addTanks,
// onResponse: (request, reply) => { // onResponse: (request, reply) => {
// validationHandler.sendPhoneVerificationCode(request, reply); // validationHandler.sendPhoneVerificationCode(request, reply);

Loading…
Cancel
Save