ashok 9 months ago
commit 4d05ada856

@ -6455,21 +6455,21 @@ exports.updatetankstatus = async (req, reply) => {
exports.listofactiveandinactivetankstatus = async (req, reply) => { // exports.listofactiveandinactivetankstatus = async (req, reply) => {
try { // try {
const { customerId } = req.params; // const { customerId } = req.params;
const status = req.query.status.toLowerCase(); // const status = req.query.status.toLowerCase();
if (!["active", "inactive"].includes(status)) { // if (!["active", "inactive"].includes(status)) {
return reply.code(400).send({ message: "Invalid status value" }); // return reply.code(400).send({ message: "Invalid status value" });
} // }
// Find tanks based on customerId and status // // Find tanks based on customerId and status
const tanks = await Tank.find({ customerId, status }); // const tanks = await Tank.find({ customerId, status });
return reply.send({ tanks }); // return reply.send({ tanks });
} catch (error) { // } catch (error) {
console.error("Error fetching tank list:", error); // console.error("Error fetching tank list:", error);
return reply.code(500).send({ message: "Internal Server Error" }); // return reply.code(500).send({ message: "Internal Server Error" });
} // }
}; // };

@ -1270,29 +1270,29 @@ module.exports = function (fastify, opts, next) {
}); });
fastify.route({ // fastify.route({
method: "GET", // method: "GET",
url: "/api/listofactiveandinactivetankstatus/:customerId", // url: "/api/listofactiveandinactivetankstatus/:customerId",
schema: { // schema: {
tags: ["Tank"], // tags: ["Tank"],
summary: "Get list of active or inactive tanks", // summary: "Get list of active or inactive tanks",
params: { // params: {
required: ["customerId"], // required: ["customerId"],
type: "object", // type: "object",
properties: { // properties: {
customerId: { type: "string", description: "Customer ID" }, // customerId: { type: "string", description: "Customer ID" },
}, // },
}, // },
querystring: { // querystring: {
type: "object", // type: "object",
properties: { // properties: {
status: { type: "string"}, // status: { type: "string"},
}, // },
}, // },
security: [{ basicAuth: [] }], // security: [{ basicAuth: [] }],
}, // },
handler: tanksController.listofactiveandinactivetankstatus, // handler: tanksController.listofactiveandinactivetankstatus,
}); // });
next(); next();

Loading…
Cancel
Save