Skip to content

Commit

Permalink
manual request
Browse files Browse the repository at this point in the history
  • Loading branch information
SIGMazer committed Dec 15, 2023
1 parent 7c9a619 commit 5ce8386
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/controllers/carController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ exports.getCar = async function getCar() {
res.status(400).json({ message: error.message });
}
}
exports.updateCarDestination = async function updateCarLocation(carID, location) {
try{
const update = {destination: location};
const options = {new: true};
const result = await Car.findByIdAndUpdate(carID, {$set: update}, options);
return result;
}
catch(error){
}
}

exports.updateCarStatus = async function updateCarStatus(carID, status) {
try {
const update = {carStatus: status};
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/readingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports.create = async (req,res) => {
await requestController.sendRequest(req.body.userID, req.body.location);
}else if(req.body.state === 1){
user = await userController.findUser(username);
functionController.notify(username, "Be careful!", "Your readings were recently unstable!");
functionController.notify(username, "Be careful!", "Your readings were recently unstable!, Click to request abmulance");
await functionController.sendEmail(user.userInfo.email, "Be careful!", "Your readings were recently unstable!");
for (let i = 0; i < relatives.length; i++) {
rel = await userController.findUser(relatives[i]);
Expand Down
1 change: 1 addition & 0 deletions src/controllers/requestController.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ exports.sendRequest = async function sendRequest(userId, location ) {
return -1;
}
carController.updateCarStatus(car, 1);
carController.updateCarDestination(car, location);
const data = new Request({
userID: userId,
requestType:1 ,
Expand Down

0 comments on commit 5ce8386

Please sign in to comment.