mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 20:29:17 +00:00
feat: add queue color to tickets list item
This commit is contained in:
@@ -4,6 +4,7 @@ import { startOfDay, endOfDay, parseISO } from "date-fns";
|
||||
import Ticket from "../../models/Ticket";
|
||||
import Contact from "../../models/Contact";
|
||||
import Message from "../../models/Message";
|
||||
import Queue from "../../models/Queue";
|
||||
|
||||
interface Request {
|
||||
searchParam?: string;
|
||||
@@ -40,6 +41,11 @@ const ListTicketsService = async ({
|
||||
model: Contact,
|
||||
as: "contact",
|
||||
attributes: ["id", "name", "number", "profilePicUrl"]
|
||||
},
|
||||
{
|
||||
model: Queue,
|
||||
as: "queue",
|
||||
attributes: ["id", "name", "color"]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ const verifyQueue = async (
|
||||
options += `*${index + 1}* - ${queue.name}\n`;
|
||||
});
|
||||
|
||||
const body = `\u200e ${greetingMessage}\n\n${options}`;
|
||||
const body = `\u200e ${greetingMessage}\n${options}`;
|
||||
|
||||
const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, body);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user