From 88b4824cf65eabec9bd1624c9847ce59f4631c28 Mon Sep 17 00:00:00 2001 From: Swift Date: Fri, 2 Feb 2024 12:45:58 +0330 Subject: [PATCH] Update captionController.js --- server/controllers/captionController.js | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/server/controllers/captionController.js b/server/controllers/captionController.js index 03ace1a..ca571ec 100644 --- a/server/controllers/captionController.js +++ b/server/controllers/captionController.js @@ -11,18 +11,39 @@ module.exports.create = [ [ body('fullName').notEmpty().withMessage(_faSr.required.name), body('national').notEmpty().withMessage(_faSr.required.national_code), - body('phoneNumber').notEmpty().withMessage(_faSr.required.phone_number), - body('email').notEmpty().withMessage(_faSr.required.email), + body('phoneNumber').notEmpty().isMobilePhone().withMessage(_faSr.required.phone_number), + body('email').notEmpty().isEmail().withMessage(_faSr.required.email), body('deviceNumber').notEmpty().withMessage(_faSr.required.field), body('receptionCode').notEmpty().withMessage(_faSr.required.field), body('caption').notEmpty().withMessage(_faSr.required.caption), - body('callType').notEmpty().withMessage(_faSr.required.field), + body('callType').notEmpty().isBoolean().withMessage(_faSr.required.field), ], checkValidations(validationResult), - (req, res) => { + async(req, res) => { - const + const complaint = await Complaint.create(req.body) + + res.status(201).json(complaint) + + } +] + + +module.exports.gets = [ + async(req, res)=>{ + const complaints = await Complaint.find() + + res.status(200).json(complaints) + + } +] + +module.exports.get = [ + async(req, res)=>{ + const complaint = await Complaint.findById(req.params.id) + + res.status(200).json(complaint) } ]