feat: add queue color to tickets list item

This commit is contained in:
canove
2021-01-11 07:22:56 -03:00
parent f642f2c788
commit 90b438025b
6 changed files with 25 additions and 24 deletions

View File

@@ -1,9 +1,7 @@
import AppError from "../../errors/AppError";
import CheckContactOpenTickets from "../../helpers/CheckContactOpenTickets";
import SetTicketMessagesAsRead from "../../helpers/SetTicketMessagesAsRead";
import Contact from "../../models/Contact";
import Ticket from "../../models/Ticket";
import User from "../../models/User";
import ShowTicketService from "./ShowTicketService";
interface TicketData {
status?: string;
@@ -27,25 +25,7 @@ const UpdateTicketService = async ({
}: Request): Promise<Response> => {
const { status, userId } = ticketData;
const ticket = await Ticket.findOne({
where: { id: ticketId },
include: [
{
model: Contact,
as: "contact",
attributes: ["id", "name", "number", "profilePicUrl"]
},
{
model: User,
as: "user",
attributes: ["id", "name"]
}
]
});
if (!ticket) {
throw new AppError("ERR_NO_TICKET_FOUND", 404);
}
const ticket = await ShowTicketService(ticketId);
await SetTicketMessagesAsRead(ticket);