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, whatsappId,
0, 0,
undefined, undefined,
queueId queueId,
true
); );
botSendMessage(ticket, `${msg}`); 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 @Column
isGroup: boolean; isGroup: boolean;
@Default(false)
@Column
isRemote: boolean;
@ForeignKey(() => StatusChatEnd) @ForeignKey(() => StatusChatEnd)
@Column @Column
statusChatEndId: number; statusChatEndId: number;

View File

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

View File

@ -21,6 +21,7 @@ interface TicketData {
statusChatEndId?: number; statusChatEndId?: number;
unreadMessages?: number; unreadMessages?: number;
whatsappId?: string | number; whatsappId?: string | number;
isRemote?: boolean;
} }
interface Request { interface Request {
@ -48,7 +49,8 @@ const UpdateTicketService = async ({
statusChatEnd, statusChatEnd,
unreadMessages, unreadMessages,
statusChatEndId, statusChatEndId,
whatsappId whatsappId,
isRemote
} = ticketData; } = ticketData;
const ticket = await ShowTicketService(ticketId); const ticket = await ShowTicketService(ticketId);
@ -76,7 +78,8 @@ const UpdateTicketService = async ({
unreadMessages, unreadMessages,
statusChatEnd, statusChatEnd,
statusChatEndId, statusChatEndId,
whatsappId whatsappId,
isRemote
}); });
await ticket.reload(); await ticket.reload();

View File

@ -246,7 +246,17 @@ const TicketListItem = ({ ticket }) => {
loading={loading} loading={loading}
onClick={e => handleAcepptTicket(ticket.id)} 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> </ButtonWithSpinner>
)} )}
</ListItem> </ListItem>