mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 20:59:16 +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 Ticket from "../../models/Ticket";
|
||||||
import Contact from "../../models/Contact";
|
import Contact from "../../models/Contact";
|
||||||
import Message from "../../models/Message";
|
import Message from "../../models/Message";
|
||||||
|
import Queue from "../../models/Queue";
|
||||||
|
|
||||||
interface Request {
|
interface Request {
|
||||||
searchParam?: string;
|
searchParam?: string;
|
||||||
@@ -40,6 +41,11 @@ const ListTicketsService = async ({
|
|||||||
model: Contact,
|
model: Contact,
|
||||||
as: "contact",
|
as: "contact",
|
||||||
attributes: ["id", "name", "number", "profilePicUrl"]
|
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 CheckContactOpenTickets from "../../helpers/CheckContactOpenTickets";
|
||||||
import SetTicketMessagesAsRead from "../../helpers/SetTicketMessagesAsRead";
|
import SetTicketMessagesAsRead from "../../helpers/SetTicketMessagesAsRead";
|
||||||
import Contact from "../../models/Contact";
|
|
||||||
import Ticket from "../../models/Ticket";
|
import Ticket from "../../models/Ticket";
|
||||||
import User from "../../models/User";
|
import ShowTicketService from "./ShowTicketService";
|
||||||
|
|
||||||
interface TicketData {
|
interface TicketData {
|
||||||
status?: string;
|
status?: string;
|
||||||
@@ -27,25 +25,7 @@ const UpdateTicketService = async ({
|
|||||||
}: Request): Promise<Response> => {
|
}: Request): Promise<Response> => {
|
||||||
const { status, userId } = ticketData;
|
const { status, userId } = ticketData;
|
||||||
|
|
||||||
const ticket = await Ticket.findOne({
|
const ticket = await ShowTicketService(ticketId);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
await SetTicketMessagesAsRead(ticket);
|
await SetTicketMessagesAsRead(ticket);
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ const verifyQueue = async (
|
|||||||
options += `*${index + 1}* - ${queue.name}\n`;
|
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);
|
const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, body);
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,15 @@ const useStyles = makeStyles(theme => ({
|
|||||||
position: "absolute",
|
position: "absolute",
|
||||||
left: "50%",
|
left: "50%",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ticketQueueColor: {
|
||||||
|
flex: "none",
|
||||||
|
width: "8px",
|
||||||
|
height: "100%",
|
||||||
|
position: "absolute",
|
||||||
|
top: "0%",
|
||||||
|
left: "0%",
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const TicketListItem = ({ ticket }) => {
|
const TicketListItem = ({ ticket }) => {
|
||||||
@@ -138,6 +147,10 @@ const TicketListItem = ({ ticket }) => {
|
|||||||
[classes.pendingTicket]: ticket.status === "pending",
|
[classes.pendingTicket]: ticket.status === "pending",
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
<span
|
||||||
|
style={{ backgroundColor: ticket.queue?.color }}
|
||||||
|
className={classes.ticketQueueColor}
|
||||||
|
></span>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar
|
<Avatar
|
||||||
src={ticket.contact.profilePicUrl && ticket.contact.profilePicUrl}
|
src={ticket.contact.profilePicUrl && ticket.contact.profilePicUrl}
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ const reducer = (state, action) => {
|
|||||||
if (action.type === "UPDATE_TICKET") {
|
if (action.type === "UPDATE_TICKET") {
|
||||||
const ticket = action.payload;
|
const ticket = action.payload;
|
||||||
|
|
||||||
|
console.log("TICKET", ticket);
|
||||||
|
|
||||||
const ticketIndex = state.findIndex(t => t.id === ticket.id);
|
const ticketIndex = state.findIndex(t => t.id === ticket.id);
|
||||||
if (ticketIndex !== -1) {
|
if (ticketIndex !== -1) {
|
||||||
state[ticketIndex] = ticket;
|
state[ticketIndex] = ticket;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ const WhatsAppModal = ({ open, onClose, whatsAppId }) => {
|
|||||||
|
|
||||||
const handleSaveWhatsApp = async values => {
|
const handleSaveWhatsApp = async values => {
|
||||||
const whatsappData = { ...values, queueIds: selectedQueueIds };
|
const whatsappData = { ...values, queueIds: selectedQueueIds };
|
||||||
console.log("SELECTED", whatsappData);
|
|
||||||
try {
|
try {
|
||||||
if (whatsAppId) {
|
if (whatsAppId) {
|
||||||
await api.put(`/whatsapp/${whatsAppId}`, whatsappData);
|
await api.put(`/whatsapp/${whatsAppId}`, whatsappData);
|
||||||
|
|||||||
Reference in New Issue
Block a user