Update complaintController.js
This commit is contained in:
@@ -1,28 +1,25 @@
|
||||
|
||||
const { body, validationResult } = require('express-validator')
|
||||
|
||||
const Complaint = require('../models/Complaint')
|
||||
const Transaction = require('../models/Transaction')
|
||||
|
||||
//const Transaction = require('../models/Transaction')
|
||||
const { _sr } = require('../plugins/serverResponses')
|
||||
const { checkValidations } = require('../plugins/controllersHelperFunctions')
|
||||
const _faSr = _sr.fa
|
||||
|
||||
|
||||
module.exports.create = [
|
||||
[
|
||||
body('fullName').notEmpty().withMessage(_faSr.required.name),
|
||||
body('national').notEmpty().withMessage(_faSr.required.national_code),
|
||||
body('phoneNumber').notEmpty().isMobilePhone('ir-IR').withMessage(_faSr.required.phone_number),
|
||||
body('email').notEmpty().isEmail().withMessage(_faSr.required.email),
|
||||
body('receptionCode').notEmpty().withMessage(_faSr.required.field).custom(async(value, { req }) => {
|
||||
const check = await Transaction.findOne({ItemReceptionTransNumber:value})
|
||||
if(!check){
|
||||
return Promise.reject(new Error("کد پذیرش معتبر نیست"))
|
||||
}else{
|
||||
return Promise.resolve()
|
||||
}
|
||||
}),
|
||||
// body('receptionCode').notEmpty().withMessage(_faSr.required.field).custom(async(value, { req }) => {
|
||||
// const check = await Transaction.findOne({ItemReceptionTransNumber:value})
|
||||
// if(!check){
|
||||
// return Promise.reject(new Error("کد پذیرش معتبر نیست"))
|
||||
// }else{
|
||||
// return Promise.resolve()
|
||||
// }
|
||||
// }),
|
||||
body('caption').notEmpty().withMessage(_faSr.required.caption),
|
||||
body('callType').notEmpty().isBoolean().withMessage(_faSr.required.field),
|
||||
body('brand').notEmpty().isBoolean().withMessage(_faSr.required.field),
|
||||
@@ -50,7 +47,6 @@ module.exports.create = [
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
module.exports.createSurvey = [
|
||||
[
|
||||
body('fullName').notEmpty().withMessage(_faSr.required.name),
|
||||
@@ -86,8 +82,6 @@ module.exports.getsComplaint = [
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
module.exports.get = [
|
||||
async(req, res)=>{
|
||||
const complaint = await Complaint.findByIdAndUpdate(
|
||||
@@ -100,7 +94,6 @@ module.exports.get = [
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
module.exports.put = [
|
||||
async(req, res)=>{
|
||||
const { complete, desc } = req.body
|
||||
|
||||
Reference in New Issue
Block a user