From dce1cda7affd117275ba106b6e7185b350b1182b Mon Sep 17 00:00:00 2001 From: Varun Date: Mon, 24 Feb 2025 17:13:53 +0530 Subject: [PATCH] added user details in response in estimation price --- src/controllers/storeController.js | 6 ++++-- src/routes/storeRoute.js | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 9245b562..40165ffc 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1600,7 +1600,8 @@ exports.editQuotationForSensor = async (req, reply) => { exports.createEstimationPrice = async (req, reply) => { try { - const { items } = req.body; + const { customerId,items } = req.body; + const user = await User.findOne({ customerId }); if (!Array.isArray(items) || items.length === 0) { return reply.code(400).send({ message: "Items array is required and cannot be empty" }); @@ -1642,7 +1643,8 @@ exports.createEstimationPrice = async (req, reply) => { return reply.code(200).send({ items: itemDetails, - estimatedTotal: totalEstimation + estimatedTotal: totalEstimation, + userDetails: user || null // Include user details in the response }); } catch (error) { diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index f1f74790..01c211c8 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -1318,6 +1318,7 @@ fastify.post("/api/createEstimationPrice", { body: { type: "object", properties: { + customerId: { type: "string", description: "Customer ID" }, items: { type: "array", description: "List of items", @@ -1325,6 +1326,7 @@ fastify.post("/api/createEstimationPrice", { type: "object", properties: { name: { type: "string", description: "Item name" }, + type: { type: "string", description: "Item type" }, quantity: { type: "string", description: "Quantity of the item" } },