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" } },