mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00

# Pull Request Template ## Description **This PR includes:** 1. Adds the ability to delete a contact from the contacts list accordion section. 2. Improves the expand/collapse transition for the accordion. Fixes [CW-4375](https://linear.app/chatwoot/issue/CW-4375/allow-users-to-delete-a-contact-from-the-contacts-page) ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Loom video https://www.loom.com/share/8c897d24737f40f6b8b29fef76ba18e2?sid=70910b9d-f3db-4d54-8bfc-820db680e537 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Pranav <pranavrajs@gmail.com>
55 lines
1.3 KiB
Vue
55 lines
1.3 KiB
Vue
<script setup>
|
|
import { ref } from 'vue';
|
|
import { useStore } from 'dashboard/composables/store';
|
|
import { useRoute } from 'vue-router';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useAlert } from 'dashboard/composables';
|
|
|
|
import Dialog from 'dashboard/components-next/dialog/Dialog.vue';
|
|
|
|
const props = defineProps({
|
|
selectedContact: {
|
|
type: Object,
|
|
default: null,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['goToContactsList']);
|
|
|
|
const { t } = useI18n();
|
|
const store = useStore();
|
|
const route = useRoute();
|
|
|
|
const dialogRef = ref(null);
|
|
|
|
const deleteContact = async id => {
|
|
if (!id) return;
|
|
|
|
try {
|
|
await store.dispatch('contacts/delete', id);
|
|
useAlert(t('CONTACTS_LAYOUT.DETAILS.DELETE_DIALOG.API.SUCCESS_MESSAGE'));
|
|
} catch (error) {
|
|
useAlert(t('CONTACTS_LAYOUT.DETAILS.DELETE_DIALOG.API.ERROR_MESSAGE'));
|
|
}
|
|
};
|
|
|
|
const handleDialogConfirm = async () => {
|
|
emit('goToContactsList');
|
|
await deleteContact(route.params.contactId || props.selectedContact.id);
|
|
dialogRef.value?.close();
|
|
};
|
|
|
|
defineExpose({ dialogRef });
|
|
</script>
|
|
|
|
<template>
|
|
<Dialog
|
|
ref="dialogRef"
|
|
type="alert"
|
|
:title="t('CONTACTS_LAYOUT.DETAILS.DELETE_DIALOG.TITLE')"
|
|
:description="t('CONTACTS_LAYOUT.DETAILS.DELETE_DIALOG.DESCRIPTION')"
|
|
:confirm-button-label="t('CONTACTS_LAYOUT.DETAILS.DELETE_DIALOG.CONFIRM')"
|
|
@confirm="handleDialogConfirm"
|
|
/>
|
|
</template>
|