added get for estimations

master^2
Varun 3 months ago
parent d724b514ad
commit 44e46043e4

@ -10,6 +10,7 @@ const libphonenumberjs = require("libphonenumber-js");
// offers http-friendly error objects.
const boom = require("boom");
const { Tankerbooking} = require("../models/tankers")
const {EstimationOrder} = require("../models/store");
// Get Data Models
const { RequestedBooking,Supplier, generateSupplierId, FriendRequest,DeliveryBoy} = require("../models/supplier")
@ -1501,3 +1502,19 @@ exports.getallsuppliers = async (req, reply) => {
throw boom.boomify(err);
}
};
exports.estimationsget = async (req, reply) => {
try {
// Find the specific tank
const estimations = await EstimationOrder.find({customerId:req.params.customerId
});
if (!estimations) {
return reply.send({ status_code: 404, error: "estimations not found" });
}
// Send the found tank within a list
reply.send({ status_code: 200, data: [estimations] });
} catch (err) {
throw boom.boomify(err);
}
};

@ -1242,6 +1242,24 @@ fastify.route({
handler: userController.getallsuppliers
});
fastify.route({
method: "GET",
url: "/api/estimationsget/:customerId",
schema: {
tags: ["User"],
description: "Get all estimations for particular customer",
summary: "Get all estimations for particular customer",
params: {
type: "object",
properties: {
customerId: { type: "string" }
},
required: ["customerId"]
}
},
handler: userController.estimationsget
});
next();

Loading…
Cancel
Save