diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 348f4c22..6aeeb842 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -623,22 +623,19 @@ exports.assignTeamMemberToQuotation = async (request, reply) => { console.log("Updated connected_gsm_date/time:", connected_gsm_date, connected_gsm_time); } - // Step 4: Check tank connection status - const tanksWithStatus = latestRecord.tanks.map(tank => { - const height = parseFloat(tank.tankHeight || "0"); - // const connectionStatus = height > 0 ? "GSM Connected" : "GSM Not Connected"; - return { - ...tank, - // connectionStatus - }; - }); + // Step 4: Check if any tank has tankHeight > 0 + const isGSMConnected = latestRecord.tanks.some(tank => parseFloat(tank.tankHeight || "0") > 0); + const gsmConnectionMessage = isGSMConnected ? "GSM Connected" : "GSM Not Connected"; + // Add tanks back without individual connection status return reply.send({ status_code: 200, message: "Success", data: { + hardwareId, + gsmStatus: gsmConnectionMessage, // ✅ GSM connection message here ...latestRecord, - tanks: tanksWithStatus + tanks: latestRecord.tanks } }); @@ -650,6 +647,7 @@ exports.assignTeamMemberToQuotation = async (request, reply) => { + exports.getByHardwareAndTankId = async (req, reply) => { try {