Skip to content

Commit

Permalink
Remove ticketers from tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jan 2, 2024
1 parent b4a1579 commit 249a874
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 108 deletions.
31 changes: 0 additions & 31 deletions src/contacts/ContactHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,37 +782,6 @@ export class ContactHistory extends RapidElement {
}

public render(): TemplateResult {
// render our older tickets as faux-events
const unfetchedTickets =
this.eventGroups.length > 0 && this.tickets
? this.tickets.map((ticket: Ticket) => {
if (ticket && ticket.status === 'open') {
const opened = new Date(ticket.opened_on).getTime() * 1000;
if (opened < this.nextBefore || this.isPurged(ticket)) {
const ticketOpenedEvent = {
type: Events.TICKET_OPENED,
ticket: {
uuid: ticket.uuid,
topic: ticket.topic,
body: ticket.body,
ticketer: ticket.ticketer,
},
created_on: ticket.opened_on,
};

const renderedEvent = renderTicketOpened(
ticketOpenedEvent,
this.handleClose,
!this.ticket
);
return html`<div class="event ticket_opened">
${renderedEvent}
</div>`;
}
}
})
: null;

return html`
${
this.fetching
Expand Down
20 changes: 2 additions & 18 deletions src/contacts/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,8 @@ export interface TicketEvent extends ContactEvent {
assignee?: User;
ticket: {
uuid: string;
ticketer: ObjectReference;
body: string;
topic?: ObjectReference;
external_id?: string;
closed_on?: string;
opened_on?: string;
};
Expand Down Expand Up @@ -1025,26 +1023,14 @@ export const renderNoteCreated = (event: TicketEvent): TemplateResult => {
</div>`;
};

const getTicketIcon = (event: TicketEvent) => {
let icon = Icon.inbox;
if (event.ticket.ticketer.name.indexOf('Email') > -1) {
icon = Icon.email;
} else if (event.ticket.ticketer.name.indexOf('Zendesk') > -1) {
icon = Icon.zendesk;
}
return icon;
};

export const renderTicketAction = (
event: TicketEvent,
action: string,
grouped: boolean
): TemplateResult => {
const reopened = new Date(event.created_on);
const icon = getTicketIcon(event);
if (grouped) {
return html`<div class="" style="display: flex">
<temba-icon name="${icon}"></temba-icon>
<temba-icon name="${Icon.inbox}"></temba-icon>
<div class="description">
${getDisplayName(event.created_by)} ${action} a
<span
Expand Down Expand Up @@ -1103,11 +1089,9 @@ export const renderTicketOpened = (
handleClose: (uuid: string) => void,
grouped: boolean
): TemplateResult => {
const icon = getTicketIcon(event);

if (grouped) {
return html`<div class="" style="display: flex">
<temba-icon name="${icon}"></temba-icon>
<temba-icon name="${Icon.inbox}"></temba-icon>

Check warning on line 1094 in src/contacts/events.ts

View check run for this annotation

Codecov / codecov/patch

src/contacts/events.ts#L1094

Added line #L1094 was not covered by tests
<div class="description">
${event.ticket.topic.name}
<span
Expand Down
1 change: 0 additions & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export interface Ticket {
opened_on: string;
status: string;
contact: ObjectReference;
ticketer: ObjectReference;
topic: ObjectReference;
assignee?: { email: string; name: string };
}
Expand Down
14 changes: 1 addition & 13 deletions test-assets/api/tickets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"results": [
{
"uuid": "bc907086-e9e7-4d5c-ba72-ef6a2059b0ae",
"ticketer": {
"uuid": "fa9e4496-14d4-41a8-8d04-e10938c17e6f",
"name": "Internal"
},
"contact": {
"uuid": "c85526ff-d025-474c-a6c6-0ec1089fc3c3",
"name": "Enrique"
Expand All @@ -20,10 +16,6 @@
},
{
"uuid": "8c3f31e9-89d4-48d9-a178-a47461d7f1b6",
"ticketer": {
"uuid": "fa9e4496-14d4-41a8-8d04-e10938c17e6f",
"name": "Internal"
},
"contact": {
"uuid": "c85526ff-d025-474c-a6c6-0ec1089fc3c3",
"name": "Enrique"
Expand All @@ -36,10 +28,6 @@
},
{
"uuid": "31e48a8e-ed79-4bf0-9aa7-5f84b92853c7",
"ticketer": {
"uuid": "fa9e4496-14d4-41a8-8d04-e10938c17e6f",
"name": "Internal"
},
"contact": {
"uuid": "c85526ff-d025-474c-a6c6-0ec1089fc3c3",
"name": "Enrique"
Expand All @@ -51,4 +39,4 @@
"closed_on": null
}
]
}
}
20 changes: 0 additions & 20 deletions test-assets/contacts/contact-tickets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"results": [
{
"uuid": "6c3156f8-ca00-4f26-b8f7-b5e131e6db7a",
"ticketer": {
"uuid": "0c3b0f9a-344c-47a5-9041-08281d71d46b",
"name": "TextIt Tickets"
},
"contact": {
"uuid": "24d64810-3315-4ff5-be85-48e3fe055bf9",
"name": "Eric Newcomer"
Expand All @@ -33,10 +29,6 @@
},
{
"uuid": "37ca10d8-b976-4885-b48c-21d3ec68b743",
"ticketer": {
"uuid": "0c3b0f9a-344c-47a5-9041-08281d71d46b",
"name": "TextIt Tickets"
},
"contact": {
"uuid": "24d64810-3315-4ff5-be85-48e3fe055bf9",
"name": "Eric Newcomer"
Expand All @@ -62,10 +54,6 @@
},
{
"uuid": "a57970e2-79ab-46d4-8761-c7cbc6a380ef",
"ticketer": {
"uuid": "0c3b0f9a-344c-47a5-9041-08281d71d46b",
"name": "TextIt Tickets"
},
"contact": {
"uuid": "24d64810-3315-4ff5-be85-48e3fe055bf9",
"name": "Eric Newcomer"
Expand All @@ -91,10 +79,6 @@
},
{
"uuid": "73de765d-eac6-4c91-b0d3-72fe9471f76f",
"ticketer": {
"uuid": "0c3b0f9a-344c-47a5-9041-08281d71d46b",
"name": "TextIt Tickets"
},
"contact": {
"uuid": "24d64810-3315-4ff5-be85-48e3fe055bf9",
"name": "Eric Newcomer"
Expand All @@ -120,10 +104,6 @@
},
{
"uuid": "d69f3568-c300-4470-b0a5-fbadd6bf0f9f",
"ticketer": {
"uuid": "0c3b0f9a-344c-47a5-9041-08281d71d46b",
"name": "TextIt Tickets"
},
"contact": {
"uuid": "24d64810-3315-4ff5-be85-48e3fe055bf9",
"name": "Eric Newcomer"
Expand Down
12 changes: 2 additions & 10 deletions test-assets/contacts/history.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
"topic": null,
"status": "O",
"subject": "Open ticket",
"body": "",
"ticketer": {
"uuid": "79101e60-60da-4893-8b7b-b865ebe50e21",
"name": "Mailgun"
}
"body": ""
},
"created_on": "2021-03-31T00:30:00.585471+00:00",
"created_by": null
Expand All @@ -38,11 +34,7 @@
"topic": null,
"status": "O",
"subject": "Open ticket",
"body": "",
"ticketer": {
"uuid": "79101e60-60da-4893-8b7b-b865ebe50e21",
"name": "Mailgun"
}
"body": ""
},
"created_on": "2021-03-31T00:30:00.585471+00:00",
"created_by": {
Expand Down
6 changes: 1 addition & 5 deletions test-assets/tickets/ticket-barack-closed.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"results": [
{
"uuid": "bc907086-e9e7-4d5c-ba72-ef6a2059b0ae",
"ticketer": {
"uuid": "fa9e4496-14d4-41a8-8d04-e10938c17e6f",
"name": "Internal"
},
"contact": {
"uuid": "contact-barack-archived",
"name": "Barack Obama"
Expand All @@ -19,4 +15,4 @@
"closed_on": "2021-04-03T21:06:59.666960Z"
}
]
}
}
6 changes: 1 addition & 5 deletions test-assets/tickets/ticket-carter-closed.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"results": [
{
"uuid": "bc907086-e9e7-4d5c-ba72-ef6a2059b0ae",
"ticketer": {
"uuid": "fa9e4496-14d4-41a8-8d04-e10938c17e6f",
"name": "Internal"
},
"contact": {
"uuid": "contact-carter-active",
"name": "Carter Beauford"
Expand All @@ -19,4 +15,4 @@
"closed_on": "2021-04-03T21:06:59.666960Z"
}
]
}
}
6 changes: 1 addition & 5 deletions test-assets/tickets/ticket-carter-open.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"results": [
{
"uuid": "bc907086-e9e7-4d5c-ba72-ef6a2059b0ae",
"ticketer": {
"uuid": "fa9e4496-14d4-41a8-8d04-e10938c17e6f",
"name": "Internal"
},
"contact": {
"uuid": "contact-carter-active",
"name": "Carter Beauford"
Expand All @@ -19,4 +15,4 @@
"closed_on": null
}
]
}
}

0 comments on commit 249a874

Please sign in to comment.