diff options
Diffstat (limited to 'interface/routes/api/citizens.js')
| -rw-r--r-- | interface/routes/api/citizens.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/interface/routes/api/citizens.js b/interface/routes/api/citizens.js index bab5222..6dad084 100644 --- a/interface/routes/api/citizens.js +++ b/interface/routes/api/citizens.js @@ -18,4 +18,38 @@ router.post('/edit', (req, res) => { } }); + +router.post('/delete', (req, res) => { + const { citizen_id } = req.body; + if (!citizen_id) { + res.status(400).json({ message: "Please fill in all fields" }); + } else { + citizensController.deleteCitizenbyId(citizen_id) + .then(() => { + res.status(200).json({ message: "Citizen deleted successfully" }); + }) + .catch((err) => { + res.status(400).json({ message: err }); + }); + } +} ); + + +router.post('/validate', (req, res) => { + const { citizen_id } = req.body; + if (!citizen_id) { + res.status(400).json({ message: "Please fill in all fields" }); + } else { + citizensController.checkCitizenId(citizen_id) + .then(( isValid ) => { + res.status(200).json({ isValid: !isValid }); + } + ) + .catch((err) => { + res.status(400).json({ message: err }); + }); + } +}); + + module.exports = router;
\ No newline at end of file |
