add survey
This commit is contained in:
@@ -20,8 +20,19 @@ module.exports.create = [
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async(req, res) => {
|
||||
const { fullName, national, phoneNumber, deviceNumber, email, receptionCode, caption, callType } = req.body
|
||||
|
||||
const complaint = await Complaint.create(req.body)
|
||||
const complaint = await Complaint.create({
|
||||
fullName,
|
||||
national,
|
||||
type:0,
|
||||
phoneNumber,
|
||||
deviceNumber,
|
||||
callType,
|
||||
email,
|
||||
receptionCode,
|
||||
caption
|
||||
})
|
||||
|
||||
res.status(201).json(complaint)
|
||||
|
||||
@@ -29,9 +40,44 @@ module.exports.create = [
|
||||
]
|
||||
|
||||
|
||||
module.exports.gets = [
|
||||
module.exports.createSurvey = [
|
||||
[
|
||||
body('fullName').notEmpty().withMessage(_faSr.required.name),
|
||||
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
||||
body('phoneNumber').notEmpty().isMobilePhone().withMessage(_faSr.required.phone_number),
|
||||
body('email').notEmpty().isEmail().withMessage(_faSr.required.email),
|
||||
body('caption').notEmpty().withMessage(_faSr.required.caption),
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async(req, res) => {
|
||||
const { fullName, national, phoneNumber, email, receptionCode, caption } = req.body
|
||||
const complaint = await Complaint.create({
|
||||
fullName,
|
||||
national,
|
||||
type:1,
|
||||
phoneNumber,
|
||||
email,
|
||||
receptionCode,
|
||||
caption
|
||||
})
|
||||
|
||||
res.status(201).json(complaint)
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.getsComplaint = [
|
||||
async(req, res)=>{
|
||||
const complaints = await Complaint.find()
|
||||
const complaints = await Complaint.find({type:0})
|
||||
|
||||
res.status(200).json(complaints)
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.getsSurvey = [
|
||||
async(req, res)=>{
|
||||
const complaints = await Complaint.find({type:1})
|
||||
|
||||
res.status(200).json(complaints)
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ const brandController = require('../controllers/brandController')
|
||||
|
||||
|
||||
/// //////////////////////////////////////////////////////// routes
|
||||
/// ///////////// survey
|
||||
router.get('/surveysPublic',hasPermission('surveys'), complaintController.getsSurvey)
|
||||
router.get('/surveys',hasPermission('surveys'), surveyController.getAllForAdmin)
|
||||
router.get('/surveys/:id',hasPermission('surveys'), surveyController.getOneForAdmin)
|
||||
|
||||
/// ///////////// Brand
|
||||
router.post('/brand',hasPermission('brands'), brandController.createbrand)
|
||||
router.get('/brand/:id',hasPermission('brands'), brandController.getbrand)
|
||||
@@ -37,7 +42,7 @@ router.delete('/brand/:id',hasPermission('brands'), brandController.deletebrand)
|
||||
|
||||
|
||||
/// ///////////// Complaint
|
||||
router.get('/complaint',hasPermission('complaint'), complaintController.gets)
|
||||
router.get('/complaint',hasPermission('complaint'), complaintController.getsComplaint)
|
||||
router.get('/complaint/:id',hasPermission('complaint'), complaintController.get)
|
||||
router.put('/complaint/:id',hasPermission('apply'), complaintController.put)
|
||||
|
||||
@@ -205,8 +210,6 @@ router.get('/smsBroadcasts/:id', hasPermission('sms'), smsBroadcastController.ge
|
||||
router.get('/usersForSMS', hasPermission('sms'), userController.get_all_users_for_admin)
|
||||
|
||||
|
||||
/// ///////////// survey
|
||||
router.get('/surveys', surveyController.getAllForAdmin)
|
||||
router.get('/surveys/:id', surveyController.getOneForAdmin)
|
||||
|
||||
|
||||
module.exports = router
|
||||
|
||||
@@ -19,6 +19,9 @@ const complaintController = require('../controllers/complaintController')
|
||||
const brandController = require('../controllers/brandController')
|
||||
|
||||
/// //////////////////////////////////////////////////////// routes
|
||||
/// ///////////// survey
|
||||
router.post('/surveys', complaintController.createSurvey)
|
||||
|
||||
/// ///////////// Brand
|
||||
router.get('/brand', brandController.getbrands)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user