diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index c97ec54a..cccaa384 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -9996,7 +9996,7 @@ if (!orders.length) { exports.sendToStoreHardwareList = async (req, reply) => { try { const { supportId, customerId } = req.params; - const { storeId } = req.body; + const { storeId, type } = req.body; if (!supportId || !customerId) { return reply.code(400).send({ error: "supportId and customerId are required in path params" }); @@ -10156,16 +10156,20 @@ exports.sendToStoreHardwareList = async (req, reply) => { } // ✅ Step: Update storeId in Orders where matching master_connections.hardwareId - const updatedHardwareIds = disconnectedIssues.map(item => item.hardwareId); - await Order.updateMany( - { - customerId, - "master_connections.hardwareId": { $in: updatedHardwareIds } - }, - { - $set: { storeId } - } - ); + // ✅ Step: Update storeId and type in Orders where matching master_connections.hardwareId +const updatedHardwareIds = disconnectedIssues.map(item => item.hardwareId); +await Order.updateMany( + { + customerId, + "master_connections.hardwareId": { $in: updatedHardwareIds } + }, + { + $set: { + storeId, + type: type // Fallback if type is not passed + } + } +); return reply.send({ status_code: 200, diff --git a/src/models/store.js b/src/models/store.js index b5926eb9..3bedc9d7 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -830,6 +830,7 @@ const orderSchema = new mongoose.Schema({ switch_type_quantity_price: { type: String, default: null }, switch_type_total_price: { type: String, default: null }, qutation_total_price: { type: String, default: null }, + type: { type: String, default: null }, status: { type: String, default: "pending" }, quatation_status: { type: String, default: "pending" }, diff --git a/src/routes/installationRoute.js b/src/routes/installationRoute.js index b13a004b..40aff23f 100644 --- a/src/routes/installationRoute.js +++ b/src/routes/installationRoute.js @@ -910,6 +910,8 @@ module.exports = function (fastify, opts, next) { required: ["storeId"], properties: { storeId: { type: "string" }, + type: { type: "string" }, + }, }, },