mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 10:42:38 +00:00
### Tools list <img width="2316" height="666" alt="CleanShot 2025-10-03 at 20 42 41@2x" src="https://github.com/user-attachments/assets/ccbffd16-804d-4eb8-9c64-2d1cfd407e4e" /> ### Tools form <img width="2294" height="2202" alt="CleanShot 2025-10-03 at 20 43 05@2x" src="https://github.com/user-attachments/assets/9f49aa09-75a1-4585-a09d-837ca64139b8" /> ## Response <img width="800" height="2144" alt="CleanShot 2025-10-03 at 20 45 56@2x" src="https://github.com/user-attachments/assets/b0c3c899-6050-4c51-baed-c8fbec5aae61" /> --------- Co-authored-by: Pranav <pranavrajs@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com>
66 lines
1.5 KiB
Vue
66 lines
1.5 KiB
Vue
<script setup>
|
|
import { ref, computed } from 'vue';
|
|
import { useStore } from 'dashboard/composables/store';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useAlert } from 'dashboard/composables';
|
|
import Dialog from 'dashboard/components-next/dialog/Dialog.vue';
|
|
|
|
const props = defineProps({
|
|
type: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
translationKey: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
entity: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
deletePayload: {
|
|
type: Object,
|
|
default: null,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['deleteSuccess']);
|
|
|
|
const { t } = useI18n();
|
|
const store = useStore();
|
|
const deleteDialogRef = ref(null);
|
|
const i18nKey = computed(() => {
|
|
return props.translationKey || props.type.toUpperCase();
|
|
});
|
|
|
|
const deleteEntity = async payload => {
|
|
if (!payload) return;
|
|
|
|
try {
|
|
await store.dispatch(`captain${props.type}/delete`, payload);
|
|
emit('deleteSuccess');
|
|
useAlert(t(`CAPTAIN.${i18nKey.value}.DELETE.SUCCESS_MESSAGE`));
|
|
} catch (error) {
|
|
useAlert(t(`CAPTAIN.${i18nKey.value}.DELETE.ERROR_MESSAGE`));
|
|
}
|
|
};
|
|
|
|
const handleDialogConfirm = async () => {
|
|
await deleteEntity(props.deletePayload || props.entity.id);
|
|
deleteDialogRef.value?.close();
|
|
};
|
|
|
|
defineExpose({ dialogRef: deleteDialogRef });
|
|
</script>
|
|
|
|
<template>
|
|
<Dialog
|
|
ref="deleteDialogRef"
|
|
type="alert"
|
|
:title="t(`CAPTAIN.${i18nKey}.DELETE.TITLE`)"
|
|
:description="t(`CAPTAIN.${i18nKey}.DELETE.DESCRIPTION`)"
|
|
:confirm-button-label="t(`CAPTAIN.${i18nKey}.DELETE.CONFIRM`)"
|
|
@confirm="handleDialogConfirm"
|
|
/>
|
|
</template>
|