mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 11:49:19 +00:00
improvement: blocking reopen a ticket when already a ticket open for that contact
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
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";
|
||||
@@ -45,6 +46,10 @@ const UpdateTicketService = async ({
|
||||
|
||||
const oldStatus = ticket.status;
|
||||
|
||||
if (oldStatus === "closed") {
|
||||
await CheckContactOpenTickets(ticket.contact.id);
|
||||
}
|
||||
|
||||
await ticket.update({
|
||||
status,
|
||||
userId
|
||||
|
||||
@@ -54,6 +54,7 @@ const TicketActionButtons = ({ ticket }) => {
|
||||
history.push("/tickets");
|
||||
}
|
||||
} catch (err) {
|
||||
setLoading(false);
|
||||
const errorMsg = err.response?.data?.error;
|
||||
if (errorMsg) {
|
||||
if (i18n.exists(`backendErrors.${errorMsg}`)) {
|
||||
|
||||
@@ -301,7 +301,7 @@ const messages = {
|
||||
ERR_DELETE_WAPP_MSG:
|
||||
"Couldn't delete message from WhatsApp. Check connections page.",
|
||||
ERR_OTHER_OPEN_TICKET:
|
||||
"There's already an open or pending ticket for this contact.",
|
||||
"There's already an open ticket for this contact.",
|
||||
ERR_SESSION_EXPIRED: "Session expired. Please login.",
|
||||
ERR_USER_CREATION_DISABLED:
|
||||
"User creation was disabled by administrator.",
|
||||
|
||||
@@ -306,8 +306,7 @@ const messages = {
|
||||
"Error al enviar el mensaje de WhatsApp. Verifique la página de conexiones.",
|
||||
ERR_DELETE_WAPP_MSG:
|
||||
"No se pudo borrar el mensaje de WhatsApp. Verifique la página de conexiones.",
|
||||
ERR_OTHER_OPEN_TICKET:
|
||||
"Ya hay un ticket abierto o pendiente para este contacto.",
|
||||
ERR_OTHER_OPEN_TICKET: "Ya hay un ticket abierto para este contacto.",
|
||||
ERR_SESSION_EXPIRED: "Sesión caducada. Inicie sesión.",
|
||||
ERR_USER_CREATION_DISABLED:
|
||||
"La creación de usuarios fue deshabilitada por el administrador.",
|
||||
|
||||
@@ -304,8 +304,7 @@ const messages = {
|
||||
"Erro ao enviar mensagem do WhatsApp. Verifique a página de conexões.",
|
||||
ERR_DELETE_WAPP_MSG:
|
||||
"Não foi possível excluir a mensagem do WhatsApp. Verifique a página de conexões.",
|
||||
ERR_OTHER_OPEN_TICKET:
|
||||
"Já existe um tíquete aberto ou pendente para este contato.",
|
||||
ERR_OTHER_OPEN_TICKET: "Já existe um tíquete aberto para este contato.",
|
||||
ERR_SESSION_EXPIRED: "Sessão expirada. Por favor entre.",
|
||||
ERR_USER_CREATION_DISABLED:
|
||||
"A criação do usuário foi desabilitada pelo administrador.",
|
||||
|
||||
Reference in New Issue
Block a user