Skip to content

Commit

Permalink
Apresentar a separação dos tickets na conversa
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh authored Jun 8, 2022
1 parent 9b80e09 commit 9392361
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 7 additions & 1 deletion backend/src/services/MessageServices/ListMessagesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ const ListMessagesService = async ({
const offset = limit * (+pageNumber - 1);

const { count, rows: messages } = await Message.findAndCountAll({
where: { ticketId },
//where: { ticketId },
//where: {contactid : ticket.contactId},
limit,
include: [
"contact",
{
model: Message,
as: "quotedMsg",
include: ["contact"]
},
{
model: Ticket,
where: {contactId: ticket.contactId },
required: true
}
],
offset,
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/components/MessagesList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const useStyles = makeStyles((theme) => ({
flexGrow: 1,
},

ticketNumber: {
color: theme.palette.secondary.main,
padding: 8,
},

messagesList: {
backgroundImage: theme.backgroundImage,
display: "flex",
Expand Down Expand Up @@ -576,6 +581,22 @@ const MessagesList = ({ ticketId, isGroup }) => {
}
};

const renderNumberTicket = (message, index) => {
if (index < messagesList.length && index > 0) {
let messageTicket = message.ticketId;
let previousMessageTicket = messagesList[index - 1].ticketId;

if (messageTicket !== previousMessageTicket) {
return (
<div key={`ticket-${message.id}`} className={classes.ticketNumber}>
#ticket: {messageTicket}
<hr />
</div>
);
}
}
};

const renderMessageDivider = (message, index) => {
if (index < messagesList.length && index > 0) {
let messageUser = messagesList[index].fromMe;
Expand Down Expand Up @@ -621,6 +642,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
<React.Fragment key={message.id}>
{renderDailyTimestamps(message, index)}
{renderMessageDivider(message, index)}
{renderNumberTicket(message, index)}
<div className={classes.messageCenter}>
<IconButton
variant="contained"
Expand Down Expand Up @@ -651,6 +673,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
<React.Fragment key={message.id}>
{renderDailyTimestamps(message, index)}
{renderMessageDivider(message, index)}
{renderNumberTicket(message, index)}
<div className={classes.messageLeft}>
<IconButton
variant="contained"
Expand Down Expand Up @@ -685,6 +708,7 @@ const MessagesList = ({ ticketId, isGroup }) => {
<React.Fragment key={message.id}>
{renderDailyTimestamps(message, index)}
{renderMessageDivider(message, index)}
{renderNumberTicket(message, index)}
<div className={classes.messageRight}>
<IconButton
variant="contained"
Expand Down

0 comments on commit 9392361

Please sign in to comment.