From 30e0d6b61029d1ec1eb462f4c976805998eb9c40 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 3 Oct 2025 20:00:40 +0530 Subject: [PATCH] feat: integrate delete --- .../i18n/locale/en/integrations.json | 7 ++++ .../routes/dashboard/captain/tools/Index.vue | 32 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/javascript/dashboard/i18n/locale/en/integrations.json b/app/javascript/dashboard/i18n/locale/en/integrations.json index 95f763668..9d5f28ff0 100644 --- a/app/javascript/dashboard/i18n/locale/en/integrations.json +++ b/app/javascript/dashboard/i18n/locale/en/integrations.json @@ -776,6 +776,13 @@ "SUCCESS_MESSAGE": "Custom tool updated successfully", "ERROR_MESSAGE": "Failed to update custom tool" }, + "DELETE": { + "TITLE": "Delete Custom Tool", + "DESCRIPTION": "Are you sure you want to delete this custom tool? This action cannot be undone.", + "CONFIRM": "Yes, delete", + "SUCCESS_MESSAGE": "Custom tool deleted successfully", + "ERROR_MESSAGE": "Failed to delete custom tool" + }, "FORM": { "TITLE": { "LABEL": "Tool Name", diff --git a/app/javascript/dashboard/routes/dashboard/captain/tools/Index.vue b/app/javascript/dashboard/routes/dashboard/captain/tools/Index.vue index ddbb6d2cf..356923c5b 100644 --- a/app/javascript/dashboard/routes/dashboard/captain/tools/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/captain/tools/Index.vue @@ -8,6 +8,7 @@ import CaptainPaywall from 'dashboard/components-next/captain/pageComponents/Pay import CustomToolsPageEmptyState from 'dashboard/components-next/captain/pageComponents/emptyStates/CustomToolsPageEmptyState.vue'; import CreateCustomToolDialog from 'dashboard/components-next/captain/pageComponents/customTool/CreateCustomToolDialog.vue'; import CustomToolCard from 'dashboard/components-next/captain/pageComponents/customTool/CustomToolCard.vue'; +import DeleteDialog from 'dashboard/components-next/captain/pageComponents/DeleteDialog.vue'; const store = useStore(); @@ -17,6 +18,7 @@ const isFetching = computed(() => uiFlags.value.fetchingList); const customToolsMeta = useMapGetter('captainCustomTools/getMeta'); const createDialogRef = ref(null); +const deleteDialogRef = ref(null); const selectedTool = ref(null); const dialogType = ref(''); @@ -38,14 +40,17 @@ const handleEdit = tool => { nextTick(() => createDialogRef.value.dialogRef.open()); }; +const handleDelete = tool => { + selectedTool.value = tool; + nextTick(() => deleteDialogRef.value.dialogRef.open()); +}; + const handleAction = ({ action, id }) => { const tool = customTools.value.find(t => t.id === id); if (action === 'edit') { handleEdit(tool); } else if (action === 'delete') { - // TODO: Implement delete - // eslint-disable-next-line no-console - console.log('Delete:', id); + handleDelete(tool); } }; @@ -54,6 +59,18 @@ const handleDialogClose = () => { selectedTool.value = null; }; +const onDeleteSuccess = () => { + selectedTool.value = null; + // Check if page will be empty after deletion + if (customTools.value.length === 1 && customToolsMeta.value.page > 1) { + // Go to previous page if current page will be empty + onPageChange(customToolsMeta.value.page - 1); + } else { + // Refresh current page + fetchCustomTools(customToolsMeta.value.page); + } +}; + onMounted(() => { fetchCustomTools(); }); @@ -109,4 +126,13 @@ onMounted(() => { :selected-tool="selectedTool" @close="handleDialogClose" /> + +