From 6f97ffe8834dcd6692c65f5858d84806c9d7ac7d Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 4 Sep 2024 14:15:26 +0530 Subject: [PATCH] change in electricals in quotation sending --- src/controllers/storeController.js | 6 ------ src/models/store.js | 12 ++---------- src/routes/storeRoute.js | 14 ++------------ 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 60f61179..1b00ea19 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1080,12 +1080,6 @@ exports.createquotationforSensor = async (req, reply) => { const { customerId, masters, slaves, motor_switches, electricals } = req.body; // Validate electricals field to ensure it's an array of objects - if (!Array.isArray(electricals) || electricals.some(e => typeof e !== 'object')) { - return reply.code(400).send({ - success: false, - message: 'Invalid data format for electricals. It should be an array of objects with "name" and "type".' - }); - } // Create a new SensorQuotation document const newQuotation = new SensorQuotation({ diff --git a/src/models/store.js b/src/models/store.js index d8200e56..06325a24 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -260,16 +260,8 @@ const sensorquotationSchema = new mongoose.Schema({ quote_status: { type: String, default: null }, quoted_amount: { type: String, default: null }, comments: { type: String, default: null }, - - - // Define electricals as an array of strings or objects - electricals: [ - { - name: { type: String }, - type: { type: String }, - - } - ] + electricals: { type: String }, + }); diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index c5010df3..cde278c2 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -789,18 +789,8 @@ fastify.post("/api/createquotationforSensor/:installationId", { masters: { type: "string" }, slaves: { type: "string" }, motor_switches: { type: "string" }, - electricals: { - type: "array", - description: "List of electrical items", - items: { - type: "object", - properties: { - name: { type: "string", description: "Name of the electrical item" }, - type: { type: "string", description: "Type of the electrical item" }, - }, - required: ["name", "type"], - }, - }, + electricals: { type: "string" }, + }, },