diff --git a/app/modules/loyalty/locales/en.json b/app/modules/loyalty/locales/en.json index cb4276eb..fee310ce 100644 --- a/app/modules/loyalty/locales/en.json +++ b/app/modules/loyalty/locales/en.json @@ -487,6 +487,7 @@ "transaction_categories": "Transaction Categories", "select_store": "Select a store...", "no_categories": "No categories configured. Click Add to create one.", + "delete_category_message": "Are you sure you want to delete this category? Existing transactions will keep the category reference but it will no longer be available for new transactions.", "admin_policy_settings": "Admin Policy Settings", "staff_pin_policy": "Staff PIN Policy", "self_enrollment": "Self Enrollment", diff --git a/app/modules/loyalty/static/admin/js/loyalty-merchant-detail.js b/app/modules/loyalty/static/admin/js/loyalty-merchant-detail.js index 36210023..7c089220 100644 --- a/app/modules/loyalty/static/admin/js/loyalty-merchant-detail.js +++ b/app/modules/loyalty/static/admin/js/loyalty-merchant-detail.js @@ -41,6 +41,8 @@ function adminLoyaltyMerchantDetail() { newCategoryTranslations: { fr: '', de: '', lb: '' }, viewingCategoryId: null, editingCategoryId: null, + showDeleteCategoryModal: false, + categoryToDelete: null, editCategoryData: { name: '', translations: { fr: '', de: '', lb: '' } }, // State @@ -353,14 +355,17 @@ function adminLoyaltyMerchantDetail() { } }, - async deleteCategory(catId) { - if (!confirm('Delete this category?')) return; + async confirmDeleteCategory() { + if (!this.categoryToDelete) return; try { - await apiClient.delete(`/admin/loyalty/stores/${this.selectedCategoryStoreId}/categories/${catId}`); + await apiClient.delete(`/admin/loyalty/stores/${this.selectedCategoryStoreId}/categories/${this.categoryToDelete}`); await this.loadCategoriesForStore(); Utils.showToast('Category deleted', 'success'); } catch (error) { Utils.showToast(error.message || 'Failed to delete category', 'error'); + } finally { + this.showDeleteCategoryModal = false; + this.categoryToDelete = null; } } }; diff --git a/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html b/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html index 4f7a36ab..8caa3522 100644 --- a/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html +++ b/app/modules/loyalty/templates/loyalty/admin/merchant-detail.html @@ -152,7 +152,7 @@ - + {{ confirm_modal( 'deleteProgramModal', _('loyalty.admin.merchant_detail.delete_title'), @@ -164,6 +164,18 @@ 'danger' ) }} + + {{ confirm_modal( + 'deleteCategoryModal', + _('loyalty.common.delete'), + _('loyalty.admin.merchant_detail.delete_category_message'), + 'confirmDeleteCategory()', + 'showDeleteCategoryModal', + _('loyalty.common.delete'), + _('loyalty.common.cancel'), + 'danger' + ) }} +