|
|
|
@ -1305,7 +1305,7 @@ exports.getSensorsByStatus = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { storeId } = req.params;
|
|
|
|
|
|
|
|
|
|
const statuses = ["pending", "available", "rejected"];
|
|
|
|
|
const statuses = ["pending", "available", "rejected","blocked"];
|
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
|
|
for (const status of statuses) {
|
|
|
|
@ -1957,8 +1957,12 @@ exports.updateInstallationId = async (req, reply) => {
|
|
|
|
|
// Update the order with the new installationId
|
|
|
|
|
const updatedOrder = await Order.findByIdAndUpdate(
|
|
|
|
|
_id,
|
|
|
|
|
{ installationId, updated_at: new Date().toISOString() }, // Also update the timestamp
|
|
|
|
|
{ new: true } // Return the updated document
|
|
|
|
|
{
|
|
|
|
|
installationId,
|
|
|
|
|
status: "installer_assigned", // Updating the status
|
|
|
|
|
updated_at: new Date().toISOString(), // Updating timestamp
|
|
|
|
|
},
|
|
|
|
|
{ new: true }
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!updatedOrder) {
|
|
|
|
@ -1977,6 +1981,31 @@ exports.updateInstallationId = async (req, reply) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getPendingOrders = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const pendingOrders = await Order.find({ status: "pending" });
|
|
|
|
|
|
|
|
|
|
if (!pendingOrders.length) {
|
|
|
|
|
return reply.send({
|
|
|
|
|
status_code: 200,
|
|
|
|
|
message: "No pending orders found",
|
|
|
|
|
data: [],
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return reply.send({
|
|
|
|
|
status_code: 200,
|
|
|
|
|
message: "Pending orders fetched successfully",
|
|
|
|
|
data: pendingOrders,
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error("Error fetching pending orders:", err);
|
|
|
|
|
return reply.status(500).send({ error: "Internal server error" });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.handleEstimation = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { customerId, items, estimatedTotal, action } = req.body;
|
|
|
|
|