Add complaint
This commit is contained in:
@@ -6,6 +6,8 @@ const PieceRequest = require('../../models/PieceRequest')
|
||||
const OldPieceRequest = require('../../models/OldPieceRequest')
|
||||
const BufferRequest = require('../../models/BufferRequest')
|
||||
const GuaranteeReport = require('../../models/GuaranteeReport')
|
||||
const Complaint = require('../../models/Complaint')
|
||||
|
||||
|
||||
module.exports.getAllNotifs = async socket => {
|
||||
try {
|
||||
@@ -32,7 +34,9 @@ module.exports.getAllNotifs = async socket => {
|
||||
BufferRequest.find({ status: 'sent' }),
|
||||
|
||||
// newGuaranteeReports
|
||||
GuaranteeReport.find({ status: 'sent', seen: false })
|
||||
GuaranteeReport.find({ status: 'sent', seen: false }),
|
||||
|
||||
Complaint.find({ read: false })
|
||||
])
|
||||
|
||||
const unreadCuMsgs = allData[0]
|
||||
@@ -43,6 +47,8 @@ module.exports.getAllNotifs = async socket => {
|
||||
const newOldPieceRequests = allData[5]
|
||||
const newBufferRequests = allData[6]
|
||||
const newGuaranteeReports = allData[7]
|
||||
const complaint = allData[8]
|
||||
|
||||
|
||||
socket.emit(`admin:allNotifs`, {
|
||||
unreadCuMsgs: unreadCuMsgs.length,
|
||||
@@ -52,7 +58,8 @@ module.exports.getAllNotifs = async socket => {
|
||||
newPieceRequests: newPieceRequests.length,
|
||||
newOldPieceRequests: newOldPieceRequests.length,
|
||||
newBufferRequests: newBufferRequests.length,
|
||||
newGuaranteeReports: newGuaranteeReports.length
|
||||
newGuaranteeReports: newGuaranteeReports.length,
|
||||
newComplaintReports:complaint.length
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
||||
@@ -41,7 +41,10 @@ module.exports.gets = [
|
||||
|
||||
module.exports.get = [
|
||||
async(req, res)=>{
|
||||
const complaint = await Complaint.findById(req.params.id)
|
||||
const complaint = await Complaint.findByIdAndUpdate(
|
||||
req.params.id,
|
||||
{read: true}
|
||||
)
|
||||
|
||||
res.status(200).json(complaint)
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ const ComplaintSchema = mongoose.Schema({
|
||||
email: String,
|
||||
receptionCode: String,
|
||||
caption: String,
|
||||
callType: Boolean
|
||||
callType: Boolean,
|
||||
read: { type: Boolean, default: false },
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user