From e7471b8e74113db9261ff4ddc373e544c85e464d Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 6 Dec 2024 14:36:24 +0530 Subject: [PATCH] feat: add contact card --- .../components-next/message/Message.vue | 22 +-- .../message/bubbles/Contact.vue | 135 ++++++++++++++++++ .../message/fixtures/textWithMedia.js | 43 ++++++ .../i18n/locale/en/conversation.json | 2 +- 4 files changed, 193 insertions(+), 9 deletions(-) create mode 100644 app/javascript/dashboard/components-next/message/bubbles/Contact.vue diff --git a/app/javascript/dashboard/components-next/message/Message.vue b/app/javascript/dashboard/components-next/message/Message.vue index de9495cf3..25f73f565 100644 --- a/app/javascript/dashboard/components-next/message/Message.vue +++ b/app/javascript/dashboard/components-next/message/Message.vue @@ -21,10 +21,11 @@ import VideoBubble from './bubbles/Video.vue'; import InstagramStoryBubble from './bubbles/InstagramStory.vue'; import AttachmentsBubble from './bubbles/Attachments.vue'; import EmailBubble from './bubbles/Email/Index.vue'; +import UnsupportedBubble from './bubbles/Unsupported.vue'; +import ContactBubble from './bubbles/Contact.vue'; const LocationBubble = defineAsyncComponent( () => import('./bubbles/Location.vue') ); -import UnsupportedBubble from './bubbles/Unsupported.vue'; import MessageError from './MessageError.vue'; import MessageMeta from './MessageMeta.vue'; @@ -253,14 +254,19 @@ const componentToRender = computed(() => { return InstagramStoryBubble; } - if (props.attachments.length === 1 && !props.content) { + if (props.attachments.length === 1) { const fileType = props.attachments[0].fileType; - if (fileType === ATTACHMENT_TYPES.IMAGE) return ImageBubble; - if (fileType === ATTACHMENT_TYPES.FILE) return FileBubble; - if (fileType === ATTACHMENT_TYPES.AUDIO) return AudioBubble; - if (fileType === ATTACHMENT_TYPES.VIDEO) return VideoBubble; - if (fileType === ATTACHMENT_TYPES.IG_REEL) return VideoBubble; - if (fileType === ATTACHMENT_TYPES.LOCATION) return LocationBubble; + + if (!props.content) { + if (fileType === ATTACHMENT_TYPES.IMAGE) return ImageBubble; + if (fileType === ATTACHMENT_TYPES.FILE) return FileBubble; + if (fileType === ATTACHMENT_TYPES.AUDIO) return AudioBubble; + if (fileType === ATTACHMENT_TYPES.VIDEO) return VideoBubble; + if (fileType === ATTACHMENT_TYPES.IG_REEL) return VideoBubble; + if (fileType === ATTACHMENT_TYPES.LOCATION) return LocationBubble; + } + // Attachment content is the name of the contact + if (fileType === ATTACHMENT_TYPES.CONTACT) return ContactBubble; } if (props.attachments.length > 1 && !props.content) { diff --git a/app/javascript/dashboard/components-next/message/bubbles/Contact.vue b/app/javascript/dashboard/components-next/message/bubbles/Contact.vue new file mode 100644 index 000000000..4d6ee8ed8 --- /dev/null +++ b/app/javascript/dashboard/components-next/message/bubbles/Contact.vue @@ -0,0 +1,135 @@ + + + diff --git a/app/javascript/dashboard/components-next/message/fixtures/textWithMedia.js b/app/javascript/dashboard/components-next/message/fixtures/textWithMedia.js index 9092fde24..05e5faf5b 100644 --- a/app/javascript/dashboard/components-next/message/fixtures/textWithMedia.js +++ b/app/javascript/dashboard/components-next/message/fixtures/textWithMedia.js @@ -73,6 +73,49 @@ export default camelcaseKeys( }, ], }, + { + id: 5296, + content: 'Shivam Mishra', + inbox_id: 486, + conversation_id: 1016, + message_type: 0, + content_type: 'text', + status: 'sent', + content_attributes: { + in_reply_to: null, + }, + created_at: 1732710571, + private: false, + source_id: null, + sender: { + additional_attributes: { + created_at_ip: '::1', + }, + custom_attributes: {}, + email: 'anthony@example.com', + id: 599, + identifier: null, + name: 'anthony', + phone_number: null, + thumbnail: '', + type: 'contact', + }, + attachments: [ + { + id: 378, + message_id: 5314, + file_type: 'contact', + account_id: 2, + coordinates_lat: 37.7937545, + coordinates_long: -122.3997472, + fallback_title: '+919999999999', + extension: null, + file_size: 287949, + width: null, + height: null, + }, + ], + }, { id: 5297, content: 'Give the team a way to reach you.', diff --git a/app/javascript/dashboard/i18n/locale/en/conversation.json b/app/javascript/dashboard/i18n/locale/en/conversation.json index 32e995379..a3ef57c8f 100644 --- a/app/javascript/dashboard/i18n/locale/en/conversation.json +++ b/app/javascript/dashboard/i18n/locale/en/conversation.json @@ -38,7 +38,7 @@ "REMOVE_SELECTION": "Remove Selection", "DOWNLOAD": "Download", "UNKNOWN_FILE_TYPE": "Unknown File", - "SAVE_CONTACT": "Save", + "SAVE_CONTACT": "Save Contact", "UPLOADING_ATTACHMENTS": "Uploading attachments...", "REPLIED_TO_STORY": "Replied to your story", "UNSUPPORTED_MESSAGE": "This message is unsupported. You can view this message on the Facebook / Instagram app.",