fix
This commit is contained in:
BIN
app/.DS_Store
vendored
BIN
app/.DS_Store
vendored
Binary file not shown.
@@ -130,13 +130,40 @@ exports.updateRoute = (req, res) => {
|
||||
});
|
||||
}
|
||||
const id = req.params.id;
|
||||
RoutePath.findByIdAndUpdate(id, req.body, { useFindAndModify: false })
|
||||
.then(data => {
|
||||
if (!data) {
|
||||
res.status(404).send({
|
||||
|
||||
RoutePath.findById(id)
|
||||
.then((currentRoute) => {
|
||||
if (!currentRoute) {
|
||||
return res.status(404).send({
|
||||
message: `Cannot update Route with id=${id}. Maybe Route was not found!`
|
||||
});
|
||||
} else res.send({ success: true, message: "Route was updated successfully." });
|
||||
}
|
||||
|
||||
const updatePayload = Object.assign({}, req.body);
|
||||
delete updatePayload.id;
|
||||
|
||||
// Safety: only allow customer_route_status updates for customers that
|
||||
// already belong to this specific route id.
|
||||
if (Array.isArray(updatePayload.route_customer_list) && Array.isArray(currentRoute.route_customer_list)) {
|
||||
const customerIdsInCurrentRoute = new Set(
|
||||
currentRoute.route_customer_list.map((c) => `${c.customer_id || c._id || ''}`)
|
||||
);
|
||||
updatePayload.route_customer_list = updatePayload.route_customer_list.map((customer) => {
|
||||
const customerId = `${customer.customer_id || customer._id || ''}`;
|
||||
if (customer.customer_route_status && customerId && !customerIdsInCurrentRoute.has(customerId)) {
|
||||
const sanitizedCustomer = Object.assign({}, customer);
|
||||
delete sanitizedCustomer.customer_route_status;
|
||||
return sanitizedCustomer;
|
||||
}
|
||||
return customer;
|
||||
});
|
||||
}
|
||||
|
||||
return RoutePath.findByIdAndUpdate(id, updatePayload, { useFindAndModify: false });
|
||||
})
|
||||
.then((data) => {
|
||||
if (!data) return;
|
||||
return res.send({ success: true, message: "Route was updated successfully." });
|
||||
})
|
||||
.catch(err => {
|
||||
res.status(500).send({
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.46cc12be.css",
|
||||
"main.js": "/static/js/main.3066488d.js",
|
||||
"main.js": "/static/js/main.c9552441.js",
|
||||
"static/js/787.c4e7f8f9.chunk.js": "/static/js/787.c4e7f8f9.chunk.js",
|
||||
"static/media/landing.png": "/static/media/landing.d4c6072db7a67dff6a78.png",
|
||||
"index.html": "/index.html",
|
||||
"main.46cc12be.css.map": "/static/css/main.46cc12be.css.map",
|
||||
"main.3066488d.js.map": "/static/js/main.3066488d.js.map",
|
||||
"main.c9552441.js.map": "/static/js/main.c9552441.js.map",
|
||||
"787.c4e7f8f9.chunk.js.map": "/static/js/787.c4e7f8f9.chunk.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.46cc12be.css",
|
||||
"static/js/main.3066488d.js"
|
||||
"static/js/main.c9552441.js"
|
||||
]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"><link rel="manifest" href="/manifest.json"/><title>Worldshine Transportation</title><script defer="defer" src="/static/js/main.3066488d.js"></script><link href="/static/css/main.46cc12be.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.10/lodash.min.js"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"><link rel="manifest" href="/manifest.json"/><title>Worldshine Transportation</title><script defer="defer" src="/static/js/main.c9552441.js"></script><link href="/static/css/main.46cc12be.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
3
app/views/static/js/main.c9552441.js
Normal file
3
app/views/static/js/main.c9552441.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user