Bhaskar 8 months ago
commit 22983aea4e

@ -1600,7 +1600,8 @@ exports.editQuotationForSensor = async (req, reply) => {
exports.createEstimationPrice = async (req, reply) => { exports.createEstimationPrice = async (req, reply) => {
try { try {
const { items } = req.body; const { customerId,items } = req.body;
const user = await User.findOne({ customerId });
if (!Array.isArray(items) || items.length === 0) { if (!Array.isArray(items) || items.length === 0) {
return reply.code(400).send({ message: "Items array is required and cannot be empty" }); 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({ return reply.code(200).send({
items: itemDetails, items: itemDetails,
estimatedTotal: totalEstimation estimatedTotal: totalEstimation,
userDetails: user || null // Include user details in the response
}); });
} catch (error) { } catch (error) {

@ -1318,6 +1318,7 @@ fastify.post("/api/createEstimationPrice", {
body: { body: {
type: "object", type: "object",
properties: { properties: {
customerId: { type: "string", description: "Customer ID" },
items: { items: {
type: "array", type: "array",
description: "List of items", description: "List of items",
@ -1325,6 +1326,7 @@ fastify.post("/api/createEstimationPrice", {
type: "object", type: "object",
properties: { properties: {
name: { type: "string", description: "Item name" }, name: { type: "string", description: "Item name" },
type: { type: "string", description: "Item type" }, type: { type: "string", description: "Item type" },
quantity: { type: "string", description: "Quantity of the item" } quantity: { type: "string", description: "Quantity of the item" }
}, },

Loading…
Cancel
Save