diff --git a/app/javascript/dashboard/components/ChatList.vue b/app/javascript/dashboard/components/ChatList.vue index f78470fed..098bc41c1 100644 --- a/app/javascript/dashboard/components/ChatList.vue +++ b/app/javascript/dashboard/components/ChatList.vue @@ -22,6 +22,7 @@ import { // https://tanstack.com/virtual/latest/docs/framework/vue/examples/variable import { DynamicScroller, DynamicScrollerItem } from 'vue-virtual-scroller'; import ChatListHeader from './ChatListHeader.vue'; +import Dialog from 'dashboard/components-next/dialog/Dialog.vue'; import ConversationFilter from 'next/filter/ConversationFilter.vue'; import SaveCustomView from 'next/filter/SaveCustomView.vue'; import ChatTypeTabs from './widgets/ChatTypeTabs.vue'; @@ -710,16 +711,6 @@ async function markAsRead(conversationId) { } } -async function deleteConversation(conversationId) { - try { - await store.dispatch('deleteConversation', conversationId); - redirectToConversationList(); - useAlert(t('CONVERSATION.SUCCESS_DELETE_CONVERSATION')); - } catch (error) { - useAlert(t('CONVERSATION.FAIL_DELETE_CONVERSATION')); - } -} - async function onAssignTeam(team, conversationId = null) { try { await store.dispatch('assignTeam', { @@ -781,6 +772,26 @@ onMounted(() => { } }); +const deleteConversationDialogRef = ref(null); +const selectedConversationId = ref(null); + +async function deleteConversation() { + try { + await store.dispatch('deleteConversation', selectedConversationId.value); + redirectToConversationList(); + selectedConversationId.value = null; + deleteConversationDialogRef.value.close(); + useAlert(t('CONVERSATION.SUCCESS_DELETE_CONVERSATION')); + } catch (error) { + useAlert(t('CONVERSATION.FAIL_DELETE_CONVERSATION')); + } +} + +const handleDelete = conversationId => { + selectedConversationId.value = conversationId; + deleteConversationDialogRef.value.open(); +}; + provide('selectConversation', selectConversation); provide('deSelectConversation', deSelectConversation); provide('assignAgent', onAssignAgent); @@ -792,7 +803,7 @@ provide('markAsUnread', markAsUnread); provide('markAsRead', markAsRead); provide('assignPriority', assignPriority); provide('isConversationSelected', isConversationSelected); -provide('deleteConversation', deleteConversation); +provide('deleteConversation', handleDelete); watch(activeTeam, () => resetAndFetchData()); @@ -956,6 +967,19 @@ watch(conversationFilters, (newVal, oldVal) => { + diff --git a/app/javascript/dashboard/i18n/locale/en/conversation.json b/app/javascript/dashboard/i18n/locale/en/conversation.json index 6cdf4f7aa..fdb7fc07a 100644 --- a/app/javascript/dashboard/i18n/locale/en/conversation.json +++ b/app/javascript/dashboard/i18n/locale/en/conversation.json @@ -118,6 +118,11 @@ "FAILED": "Couldn't change priority. Please try again." } }, + "DELETE_CONVERSATION": { + "TITLE": "Delete conversation #{conversationId}", + "DESCRIPTION": "Are you sure you want to delete this conversation?", + "CONFIRM": "Delete" + }, "CARD_CONTEXT_MENU": { "PENDING": "Mark as pending", "RESOLVED": "Mark as resolved",