From 0a3840501e18ac68d87462b494dd2b70f57eba70 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 4 Dec 2024 17:08:06 +0530 Subject: [PATCH] feat: add error case --- .../message/EmailMessages.story.vue | 16 ++++++++++++++++ .../components-next/message/Message.vue | 2 +- .../components-next/message/bubbles/Email.vue | 17 +++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/javascript/dashboard/components-next/message/EmailMessages.story.vue b/app/javascript/dashboard/components-next/message/EmailMessages.story.vue index 9f687b4fa..de943216f 100644 --- a/app/javascript/dashboard/components-next/message/EmailMessages.story.vue +++ b/app/javascript/dashboard/components-next/message/EmailMessages.story.vue @@ -3,6 +3,17 @@ import Message from './Message.vue'; import simpleEmail from './fixtures/simpleEmail.js'; import newsletterEmail from './fixtures/newsletterEmail.js'; + +const failedEmail = { + ...simpleEmail[0], + status: 'failed', + senderId: 1, + senderType: 'User', + contentAttributes: { + ...simpleEmail[0].contentAttributes, + externalError: 'Failed to send email', + }, +}; + +
+ +
+
diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index 376e280f9..4cae4797e 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -140,13 +140,13 @@ const props = defineProps({ */ const variant = computed(() => { if (props.private) return MESSAGE_VARIANTS.PRIVATE; - if (props.status === MESSAGE_STATUS.FAILED) return MESSAGE_VARIANTS.ERROR; if (props.isEmailInbox) { const emailInboxTypes = [MESSAGE_TYPES.INCOMING, MESSAGE_TYPES.OUTGOING]; if (emailInboxTypes.includes(props.messageType)) { return MESSAGE_VARIANTS.EMAIL; } } + if (props.status === MESSAGE_STATUS.FAILED) return MESSAGE_VARIANTS.ERROR; const variants = { [MESSAGE_TYPES.INCOMING]: MESSAGE_VARIANTS.USER, diff --git a/app/javascript/dashboard/components-next/message/bubbles/Email.vue b/app/javascript/dashboard/components-next/message/bubbles/Email.vue index 1a68ff501..f025d466b 100644 --- a/app/javascript/dashboard/components-next/message/bubbles/Email.vue +++ b/app/javascript/dashboard/components-next/message/bubbles/Email.vue @@ -3,6 +3,7 @@ import { computed, useTemplateRef, ref, watch } from 'vue'; import { Letter } from 'vue-letter'; import Icon from 'next/icon/Icon.vue'; import BaseBubble from 'next/message/bubbles/Base.vue'; +import { MESSAGE_STATUS } from '../constants'; const props = defineProps({ content: { @@ -13,6 +14,11 @@ const props = defineProps({ type: Object, default: () => ({}), }, + status: { + type: String, + required: true, + validator: value => Object.values(MESSAGE_STATUS).includes(value), + }, sender: { type: Object, default: () => ({}), @@ -33,6 +39,10 @@ watch( { immediate: true } ); +const hasError = computed(() => { + return props.status === MESSAGE_STATUS.FAILED; +}); + const contentToShow = computed(() => { return props.contentAttributes?.email?.htmlContent?.full ?? props.content; }); @@ -86,10 +96,13 @@ const showMeta = computed(() => {
- {{ senderName }} + + {{ senderName }} + <{{ fromEmail[0] }}>