Edit surveys
This commit is contained in:
@@ -75,14 +75,7 @@ module.exports.getsComplaint = [
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.getsSurvey = [
|
||||
async(req, res)=>{
|
||||
const complaints = await Complaint.find({type:1})
|
||||
|
||||
res.status(200).json(complaints)
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.get = [
|
||||
async(req, res)=>{
|
||||
|
||||
@@ -27,6 +27,7 @@ module.exports.create = [
|
||||
coast,
|
||||
description,
|
||||
code,
|
||||
type:0,
|
||||
user: req.user_id
|
||||
}
|
||||
|
||||
@@ -38,6 +39,43 @@ module.exports.create = [
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.createPublic = [
|
||||
(req, res) => {
|
||||
const {
|
||||
purchasedProduct,
|
||||
guaranteeWorkFlow,
|
||||
employeeResponsibility,
|
||||
serviceQuality,
|
||||
serviceTime,
|
||||
repairQuality,
|
||||
coast,
|
||||
description,
|
||||
code
|
||||
} = req.body
|
||||
|
||||
const data = {
|
||||
purchasedProduct,
|
||||
guaranteeWorkFlow,
|
||||
employeeResponsibility,
|
||||
serviceQuality,
|
||||
serviceTime,
|
||||
repairQuality,
|
||||
coast,
|
||||
description,
|
||||
code,
|
||||
type:1
|
||||
}
|
||||
|
||||
const survey = new Survey(data)
|
||||
|
||||
survey.save(err => {
|
||||
if (err) return res500(res, err)
|
||||
return res.json({ message: _faSr.response.success_save })
|
||||
})
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
module.exports.getAllForUser = [
|
||||
(req, res) => {
|
||||
Survey.find({ user: req.user_id }, (err, data) => {
|
||||
@@ -49,7 +87,7 @@ module.exports.getAllForUser = [
|
||||
|
||||
module.exports.getAllForAdmin = [
|
||||
(req, res) => {
|
||||
Survey.find({})
|
||||
Survey.find({type:req.query.type || 0})
|
||||
.populate('user', 'first_name last_name')
|
||||
.exec((err, data) => {
|
||||
if (err) return res500(res, err)
|
||||
|
||||
@@ -10,6 +10,14 @@ const SurveySchema = mongoose.Schema({
|
||||
coast: { type: Number, enum: [1, 2, 3, 4, 5] },
|
||||
description: String,
|
||||
code: String,
|
||||
fullName: String,
|
||||
national: String,
|
||||
phoneNumber: String,
|
||||
email: String,
|
||||
type: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
user: { type: mongoose.ObjectId, ref: 'User' },
|
||||
})
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ 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)
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@ const representationController = require('../controllers/representationControlle
|
||||
const announcementController = require('../controllers/announcementController')
|
||||
const complaintController = require('../controllers/complaintController')
|
||||
const brandController = require('../controllers/brandController')
|
||||
const surveyController = require('../controllers/surveyController')
|
||||
|
||||
/// //////////////////////////////////////////////////////// routes
|
||||
/// ///////////// survey
|
||||
router.post('/surveys', complaintController.createSurvey)
|
||||
/// // survey
|
||||
router.post('/survey', surveyController.createPublic)
|
||||
|
||||
/// ///////////// Brand
|
||||
router.get('/brand', brandController.getbrands)
|
||||
|
||||
Reference in New Issue
Block a user