Backend using new tickets logic

This commit is contained in:
canove
2020-07-17 15:20:53 -03:00
parent 9687a1ce13
commit 9da6c3ceb2
3 changed files with 132 additions and 88 deletions

View File

@@ -1,4 +1,3 @@
const { validationResult } = require("express-validator");
const jwt = require("jsonwebtoken");
const authConfig = require("../config/auth");

View File

@@ -4,7 +4,19 @@ const Ticket = require("../models/Ticket");
const Contact = require("../models/Contact");
exports.index = async (req, res) => {
const { status = "" } = req.query;
let whereCondition;
if (!status) {
whereCondition = ["pending", "open"];
} else {
whereCondition = [status];
}
const tickets = await Ticket.findAll({
where: {
status: { [Sequelize.Op.or]: whereCondition },
},
include: [
{
model: Contact,