From b581d19c93fd757a5c7eee9ce2660af2acbaa61f Mon Sep 17 00:00:00 2001 From: iamsivin Date: Fri, 15 Mar 2024 13:35:23 +0530 Subject: [PATCH] feat: Add sla types --- .../dashboard/i18n/locale/en/inbox.json | 5 ++- .../dashboard/inbox/components/InboxCard.vue | 40 ++++++++++--------- .../inbox/components/helpers/constants.js | 13 ++++++ .../FluentIcon/dashboard-icons.json | 1 + 4 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 app/javascript/dashboard/routes/dashboard/inbox/components/helpers/constants.js diff --git a/app/javascript/dashboard/i18n/locale/en/inbox.json b/app/javascript/dashboard/i18n/locale/en/inbox.json index 52a16af69..52e9fc833 100644 --- a/app/javascript/dashboard/i18n/locale/en/inbox.json +++ b/app/javascript/dashboard/i18n/locale/en/inbox.json @@ -18,7 +18,10 @@ }, "TYPES": { "CONVERSATION_MENTION": "Mention", - "CONVERSATION_ASSIGNMENT": "Assigned to you" + "CONVERSATION_ASSIGNMENT": "Assigned to you", + "SLA_MISSED_FIRST_RESPONSE": "SLA breach", + "SLA_MISSED_NEXT_RESPONSE": "SLA breach", + "SLA_MISSED_RESOLUTION": "SLA breach" }, "MENU_ITEM": { "MARK_AS_READ": "Mark as read", diff --git a/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue b/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue index 81b0fb20f..b42f00999 100644 --- a/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue +++ b/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue @@ -62,19 +62,21 @@ :parent-element-width="inboxCardInfoElementWidth" />
- {{ notificationTypes }} + {{ notificationDetails.text }}
@@ -111,6 +113,7 @@ import { } from 'dashboard/helper/snoozeHelpers'; import { INBOX_EVENTS } from 'dashboard/helper/AnalyticsHelper/events'; import { debounce } from '@chatwoot/utils'; +import { NOTIFICATION_TYPES_MAPPING } from './helpers/constants'; const OBSERVER_DEBOUNCE_TIME = 100; @@ -162,24 +165,23 @@ export default { pushTitle() { return this.notificationItem?.push_message_body; }, - notificationTypes() { - const usedTypes = ['CONVERSATION_MENTION', 'CONVERSATION_ASSIGNMENT']; - const { notification_type: notificationType } = this.notificationItem; + hasNotificationType() { + return this.notificationItem?.notification_type; + }, + notificationDetails() { + const { notification_type: notificationType = '' } = + this.notificationItem || {}; const upperCaseType = notificationType?.toUpperCase(); - return usedTypes.includes(upperCaseType) + const text = NOTIFICATION_TYPES_MAPPING[upperCaseType] ? this.$t(`INBOX.TYPES.${upperCaseType}`) : ''; - }, - notificationTypeIcon() { - const { notification_type: notificationType } = this.notificationItem; - if (notificationType === 'conversation_mention') { - return 'alternate-email'; - } - if (notificationType === 'conversation_assignment') { - return 'keyboard-double-arrow-right'; - } - return ''; + const [icon, color] = NOTIFICATION_TYPES_MAPPING[upperCaseType] || [ + '', + 'text-woot-500 dark:text-woot-500', + ]; + + return { text, icon, color }; }, lastActivityAt() { const dynamicTime = this.dynamicTime( diff --git a/app/javascript/dashboard/routes/dashboard/inbox/components/helpers/constants.js b/app/javascript/dashboard/routes/dashboard/inbox/components/helpers/constants.js new file mode 100644 index 000000000..47001abd1 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/inbox/components/helpers/constants.js @@ -0,0 +1,13 @@ +export const NOTIFICATION_TYPES_MAPPING = { + CONVERSATION_MENTION: ['alternate-email', 'text-woot-500 dark:text-woot-500'], + CONVERSATION_ASSIGNMENT: [ + 'keyboard-double-arrow-right', + 'text-woot-500 dark:text-woot-500', + ], + SLA_MISSED_FIRST_RESPONSE: [ + 'heart-broken', + 'text-red-500 dark:text-woot-500', + ], + SLA_MISSED_NEXT_RESPONSE: ['heart-broken', 'text-red-500 dark:text-woot-500'], + SLA_MISSED_RESOLUTION: ['heart-broken', 'text-red-500 dark:text-woot-500'], +}; diff --git a/app/javascript/shared/components/FluentIcon/dashboard-icons.json b/app/javascript/shared/components/FluentIcon/dashboard-icons.json index 42549de16..cc00e629d 100644 --- a/app/javascript/shared/components/FluentIcon/dashboard-icons.json +++ b/app/javascript/shared/components/FluentIcon/dashboard-icons.json @@ -117,6 +117,7 @@ "globe-outline": "M12 1.999c5.524 0 10.002 4.478 10.002 10.002 0 5.523-4.478 10.001-10.002 10.001-5.524 0-10.002-4.478-10.002-10.001C1.998 6.477 6.476 1.999 12 1.999ZM14.939 16.5H9.06c.652 2.414 1.786 4.002 2.939 4.002s2.287-1.588 2.939-4.002Zm-7.43 0H4.785a8.532 8.532 0 0 0 4.094 3.411c-.522-.82-.953-1.846-1.27-3.015l-.102-.395Zm11.705 0h-2.722c-.324 1.335-.792 2.5-1.373 3.411a8.528 8.528 0 0 0 3.91-3.127l.185-.283ZM7.094 10H3.735l-.005.017a8.525 8.525 0 0 0-.233 1.984c0 1.056.193 2.067.545 3h3.173a20.847 20.847 0 0 1-.123-5Zm8.303 0H8.603a18.966 18.966 0 0 0 .135 5h6.524a18.974 18.974 0 0 0 .135-5Zm4.868 0h-3.358c.062.647.095 1.317.095 2a20.3 20.3 0 0 1-.218 3h3.173a8.482 8.482 0 0 0 .544-3c0-.689-.082-1.36-.236-2ZM8.88 4.09l-.023.008A8.531 8.531 0 0 0 4.25 8.5h3.048c.314-1.752.86-3.278 1.583-4.41ZM12 3.499l-.116.005C10.62 3.62 9.396 5.622 8.83 8.5h6.342c-.566-2.87-1.783-4.869-3.045-4.995L12 3.5Zm3.12.59.107.175c.669 1.112 1.177 2.572 1.475 4.237h3.048a8.533 8.533 0 0 0-4.339-4.29l-.291-.121Z", "headset-add-outline": "M23 6.5C23 3.46243 20.5376 1 17.5 1C14.4624 1 12 3.46243 12 6.5C12 9.53757 14.4624 12 17.5 12C20.5376 12 23 9.53757 23 6.5ZM18.0006 7.00001L18.0011 9.50352C18.0011 9.77966 17.7773 10.0035 17.5011 10.0035C17.225 10.0035 17.0011 9.77966 17.0011 9.50352L17.0006 7.00001H14.4956C14.2197 7.00001 13.9961 6.77615 13.9961 6.50001C13.9961 6.22387 14.2197 6.00001 14.4956 6.00001H17.0005L17 3.49927C17 3.22313 17.2239 2.99927 17.5 2.99927C17.7761 2.99927 18 3.22313 18 3.49927L18.0005 6.00001H20.4966C20.7725 6.00001 20.9961 6.22387 20.9961 6.50001C20.9961 6.77615 20.7725 7.00001 20.4966 7.00001H18.0006ZM17.5 13C18.0163 13 18.5185 12.9398 19 12.8261V15C19 16.0544 18.1841 16.9182 17.1493 16.9945L17 17H15C14.4872 17 14.0645 16.614 14.0067 16.1166L14 16V12L14.0002 11.9783C14.4634 12.2748 14.9666 12.5142 15.5 12.6865V15.5H17C17.2455 15.5 17.4496 15.3231 17.4919 15.0899L17.5 15V13ZM12.0218 3.00003C11.7171 3.47601 11.4727 3.99433 11.2994 4.5442C8.59265 4.88833 6.5 7.19978 6.5 10V11H9C9.55228 11 10 11.4477 10 12V16C10 16.5523 9.55228 17 9 17H6.5V17.25C6.5 18.4409 7.42516 19.4156 8.59595 19.4948L8.75 19.5L9.87812 19.4997C10.1871 18.626 11.0204 18 12 18C13.2426 18 14.25 19.0074 14.25 20.25C14.25 21.4926 13.2426 22.5 12 22.5C11.0201 22.5 10.1864 21.8735 9.87776 20.9992L8.75 21C6.74574 21 5.10873 19.4276 5.0052 17.4492L5 17.25V10C5 6.13401 8.13401 3 12 3L12.0218 3.00003ZM12 19.5C11.5858 19.5 11.25 19.8358 11.25 20.25C11.25 20.6642 11.5858 21 12 21C12.4142 21 12.75 20.6642 12.75 20.25C12.75 19.8358 12.4142 19.5 12 19.5ZM8.5 12.5H6.5V15.5H8.5V12.5Z", "headphones-sound-wave-outline": "M3.5 12a8.5 8.5 0 0 1 17 0v2h-2.25a.75.75 0 0 0-.75.75v6.5c0 .414.336.75.75.75H19a3 3 0 0 0 3-3v-7c0-5.523-4.477-10-10-10S2 6.477 2 12v7a3 3 0 0 0 3 3h.75a.75.75 0 0 0 .75-.75v-6.5a.75.75 0 0 0-.75-.75H3.5v-2Zm17 3.5V19a1.5 1.5 0 0 1-1.5 1.5v-5h1.5ZM3.5 19v-3.5H5v5A1.5 1.5 0 0 1 3.5 19Zm9.25-7.25a.75.75 0 0 0-1.5 0v10.5a.75.75 0 0 0 1.5 0v-10.5Zm-4 2.25a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-4.5a.75.75 0 0 1 .75-.75Zm7.25.75a.75.75 0 0 0-1.5 0v4.5a.75.75 0 0 0 1.5 0v-4.5Z", + "heart-broken-outline": "M10.725 19.85q-2.9-2.55-4.625-4.225T3.463 12.75q-.913-1.2-1.188-2.162T2 8.5q0-2.3 1.6-3.9T7.5 3q1.125 0 2.175.412T11.55 4.6l-1.175 4.125q-.125.5.163.888t.787.387H13l-.65 6.35q-.025.2.163.225t.237-.15L14.6 10.3q.15-.5-.15-.9t-.8-.4H12l1.775-5.3q.625-.35 1.313-.525T16.5 3q2.3 0 3.9 1.6T22 8.5q0 1.125-.288 2.113t-1.2 2.212Q19.6 14.05 17.9 15.713t-4.55 4.137q-.55.475-1.312.475t-1.313-.475ZM4 8.5q0 .75.263 1.475t.937 1.65q.675.925 1.825 2.175t2.925 3.05q.1.1.213.063t.137-.163l.475-4.75q-1.3 0-2.075-1.012T8.275 8.75l.95-3.325q-.4-.2-.838-.313T7.5 5Q6.05 5 5.025 6.025T4 8.5Zm16 0q0-1.45-1.025-2.475T16.5 5q-.275 0-.55.038t-.55.137L14.8 7q1.125.3 1.662 1.338t.188 2.162l-1.3 4.275q-.05.125.088.213t.262-.038q1.375-1.4 2.225-2.325t1.313-1.613q.462-.687.612-1.25T20 8.5Zm-3.35 2ZM8.275 8.75Z", "image-outline": "M17.75 3A3.25 3.25 0 0 1 21 6.25v11.5A3.25 3.25 0 0 1 17.75 21H6.25A3.25 3.25 0 0 1 3 17.75V6.25A3.25 3.25 0 0 1 6.25 3h11.5Zm.58 16.401-5.805-5.686a.75.75 0 0 0-.966-.071l-.084.07-5.807 5.687c.182.064.378.099.582.099h11.5c.203 0 .399-.035.58-.099l-5.805-5.686L18.33 19.4ZM17.75 4.5H6.25A1.75 1.75 0 0 0 4.5 6.25v11.5c0 .208.036.408.103.594l5.823-5.701a2.25 2.25 0 0 1 3.02-.116l.128.116 5.822 5.702c.067-.186.104-.386.104-.595V6.25a1.75 1.75 0 0 0-1.75-1.75Zm-2.498 2a2.252 2.252 0 1 1 0 4.504 2.252 2.252 0 0 1 0-4.504Zm0 1.5a.752.752 0 1 0 0 1.504.752.752 0 0 0 0-1.504Z", "info-outline": "M12 1.999c5.524 0 10.002 4.478 10.002 10.002 0 5.523-4.478 10.001-10.002 10.001-5.524 0-10.002-4.478-10.002-10.001C1.998 6.477 6.476 1.999 12 1.999Zm0 1.5a8.502 8.502 0 1 0 0 17.003A8.502 8.502 0 0 0 12 3.5Zm-.004 7a.75.75 0 0 1 .744.648l.007.102.003 5.502a.75.75 0 0 1-1.493.102l-.007-.101-.003-5.502a.75.75 0 0 1 .75-.75ZM12 7.003a.999.999 0 1 1 0 1.997.999.999 0 0 1 0-1.997Z", "key-outline": "M15 6a1 1 0 1 1-2 0a1 1 0 0 1 2 0Zm-2.5-4C9.424 2 7 4.424 7 7.5c0 .397.04.796.122 1.175c.058.27-.008.504-.142.638l-4.54 4.54A1.5 1.5 0 0 0 2 14.915V16.5A1.5 1.5 0 0 0 3.5 18h2A1.5 1.5 0 0 0 7 16.5V16h1a1 1 0 0 0 1-1v-1h1a1 1 0 0 0 1-1v-.18c.493.134 1.007.18 1.5.18c3.076 0 5.5-2.424 5.5-5.5S15.576 2 12.5 2ZM8 7.5C8 4.976 9.976 3 12.5 3S17 4.976 17 7.5S15.024 12 12.5 12c-.66 0-1.273-.095-1.776-.347A.5.5 0 0 0 10 12.1v.9H9a1 1 0 0 0-1 1v1H7a1 1 0 0 0-1 1v.5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5v-1.586a.5.5 0 0 1 .146-.353l4.541-4.541c.432-.432.522-1.044.412-1.556A4.619 4.619 0 0 1 8 7.5Z",