Feat: Added 'New ticket" option on ticket list

This commit is contained in:
canove
2020-07-28 08:38:22 -03:00
parent 725adfaf6a
commit 915ee712dc
3 changed files with 92 additions and 81 deletions

View File

@@ -48,8 +48,18 @@ exports.index = async (req, res) => {
};
exports.store = async (req, res) => {
const io = getIO();
const ticket = await Ticket.create(req.body);
const contact = await ticket.getContact();
const serializaedTicket = { ...ticket.dataValues, contact: contact };
io.to("notification").emit("ticket", {
action: "create",
ticket: serializaedTicket,
});
res.status(200).json(ticket);
};