From 15ca1da7de25dba6006b20b8b74ddbac75940f9e Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 12 Mar 2025 17:07:22 +0530 Subject: [PATCH] changes in qc --- src/controllers/storeController.js | 6 +++--- src/routes/storeRoute.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 45cc2722..3781520b 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1301,7 +1301,7 @@ exports.deleteSensorById = async (req, reply) => { exports.updateSensorQC = async (req, reply) => { try { - const { _id } = req.params; + const { hardwareId } = req.params; let updateData = req.body; const allowedFields = ['qccheck', 'qcby', 'comment', 'status', 'quality_check_details']; @@ -1325,13 +1325,13 @@ exports.updateSensorQC = async (req, reply) => { // Find the sensor by ID const updatedSensor = await Insensors.findByIdAndUpdate( - _id, + hardwareId, filteredUpdateData, { new: true } ); if (!updatedSensor) { - return reply.code(404).send({ message: 'Sensor not found' }); + return reply.code(409).send({ message: 'Sensor not found' }); } // Update stock based on QC result diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index fd1ca988..2fa07d09 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -1182,6 +1182,7 @@ fastify.post('/api/getSensorByHardwareId/:storeId', { handler: storeController.getSensorByHardwareId, }); + fastify.post("/api/updateSensorById/:_id", { schema: { description: "Edit specific sensor fields", @@ -1213,16 +1214,16 @@ fastify.post("/api/updateSensorById/:_id", { }); -fastify.post('/api/updateSensorQC/:_id', { +fastify.post('/api/updateSensorQC/:hardwareId', { schema: { description: 'Edit specific sensor QC fields', tags: ['Store-Data'], summary: 'Update QC fields of a sensor', params: { - required: ['_id'], + required: ['_ihardwareIdd'], type: 'object', properties: { - _id: { type: 'string', description: 'Sensor ID' }, + hardwareId: { type: 'string', description: 'Sensor ID' }, }, }, body: {