diff --git a/src/controllers/carController.js b/src/controllers/carController.js index 2612666..20a4760 100644 --- a/src/controllers/carController.js +++ b/src/controllers/carController.js @@ -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}; diff --git a/src/controllers/readingController.js b/src/controllers/readingController.js index f5411e0..10741aa 100644 --- a/src/controllers/readingController.js +++ b/src/controllers/readingController.js @@ -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]); diff --git a/src/controllers/requestController.js b/src/controllers/requestController.js index d81af7a..7f42a23 100644 --- a/src/controllers/requestController.js +++ b/src/controllers/requestController.js @@ -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 ,