feat: Add new field to Tickets table to differentiate campaign tickets

feat-scaling-ticket-remote-creation
adriano 2024-04-15 08:12:29 -03:00
parent bfae2956a5
commit c9750222c0
7 changed files with 42 additions and 29 deletions

View File

@ -264,7 +264,8 @@ export const remoteTicketCreation = async (
whatsappId,
0,
undefined,
queueId
queueId,
true
);
botSendMessage(ticket, `${msg}`);
}

View File

@ -0,0 +1,15 @@
import { QueryInterface, DataTypes } from "sequelize";
module.exports = {
up: (queryInterface: QueryInterface) => {
return queryInterface.addColumn("Tickets", "isRemote", {
type: DataTypes.BOOLEAN,
allowNull: true,
defaultValue: false
});
},
down: (queryInterface: QueryInterface) => {
return queryInterface.removeColumn("Tickets", "isRemote");
}
};

View File

@ -1,22 +0,0 @@
import { QueryInterface } from "sequelize";
module.exports = {
up: (queryInterface: QueryInterface) => {
return queryInterface.bulkInsert(
"Settings",
[
{
key: "filterMediasByType",
value: "disabled",
createdAt: new Date(),
updatedAt: new Date()
}
],
{}
);
},
down: (queryInterface: QueryInterface) => {
return queryInterface.bulkDelete("Settings", {});
}
};

View File

@ -43,6 +43,10 @@ class Ticket extends Model<Ticket> {
@Column
isGroup: boolean;
@Default(false)
@Column
isRemote: boolean;
@ForeignKey(() => StatusChatEnd)
@Column
statusChatEndId: number;

View File

@ -14,7 +14,8 @@ const FindOrCreateTicketService = async (
whatsappId: number,
unreadMessages: number,
groupContact?: Contact,
queueId?: number | string
queueId?: number | string,
isRemote?: boolean
): Promise<Ticket> => {
try {
let ticket;
@ -106,7 +107,8 @@ const FindOrCreateTicketService = async (
queueId,
unreadMessages,
whatsappId,
phoneNumberId
phoneNumberId,
isRemote
});
}

View File

@ -21,6 +21,7 @@ interface TicketData {
statusChatEndId?: number;
unreadMessages?: number;
whatsappId?: string | number;
isRemote?: boolean;
}
interface Request {
@ -48,7 +49,8 @@ const UpdateTicketService = async ({
statusChatEnd,
unreadMessages,
statusChatEndId,
whatsappId
whatsappId,
isRemote
} = ticketData;
const ticket = await ShowTicketService(ticketId);
@ -68,7 +70,7 @@ const UpdateTicketService = async ({
if (oldStatus === "closed") {
await CheckContactOpenTickets(ticket.contact.id, ticket.whatsappId);
}
await ticket.update({
status,
queueId,
@ -76,7 +78,8 @@ const UpdateTicketService = async ({
unreadMessages,
statusChatEnd,
statusChatEndId,
whatsappId
whatsappId,
isRemote
});
await ticket.reload();

View File

@ -246,7 +246,17 @@ const TicketListItem = ({ ticket }) => {
loading={loading}
onClick={e => handleAcepptTicket(ticket.id)}
>
{i18n.t("ticketsList.buttons.accept")}
{/* {i18n.t("ticketsList.buttons.accept")} */}
<>
{/* {i18n.t("ticketsList.buttons.accept")}<br />CAMPANHA */}
{ticket?.isRemote ? (
<>{i18n.t("ticketsList.buttons.accept")}<br />CAMPANHA</>
) : (
<>{i18n.t("ticketsList.buttons.accept")}</>
)}
</>
</ButtonWithSpinner>
)}
</ListItem>