fix(loyalty): use confirm modal for category deletion
Some checks are pending
Some checks are pending
Replace browser confirm() dialog with the shared confirm_modal macro for category deletion. Matches the existing program delete pattern. Shows warning about impact on existing transactions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
<!-- Delete Program Confirmation Modal -->
|
||||
{{ confirm_modal(
|
||||
'deleteProgramModal',
|
||||
_('loyalty.admin.merchant_detail.delete_title'),
|
||||
@@ -164,6 +164,18 @@
|
||||
'danger'
|
||||
) }}
|
||||
|
||||
<!-- Delete Category Confirmation Modal -->
|
||||
{{ confirm_modal(
|
||||
'deleteCategoryModal',
|
||||
_('loyalty.common.delete'),
|
||||
_('loyalty.admin.merchant_detail.delete_category_message'),
|
||||
'confirmDeleteCategory()',
|
||||
'showDeleteCategoryModal',
|
||||
_('loyalty.common.delete'),
|
||||
_('loyalty.common.cancel'),
|
||||
'danger'
|
||||
) }}
|
||||
|
||||
<!-- Location Breakdown -->
|
||||
<div x-show="locations.length > 0" class="px-4 py-3 mb-8 bg-white rounded-lg shadow-md dark:bg-gray-800">
|
||||
<h3 class="mb-4 text-lg font-semibold text-gray-700 dark:text-gray-200">
|
||||
@@ -287,7 +299,7 @@
|
||||
class="text-sm" :class="cat.is_active ? 'text-orange-500 hover:text-orange-700' : 'text-green-500 hover:text-green-700'">
|
||||
<span x-html="$icon(cat.is_active ? 'ban' : 'play', 'w-4 h-4')"></span>
|
||||
</button>
|
||||
<button @click="deleteCategory(cat.id)" type="button"
|
||||
<button @click="categoryToDelete = cat.id; showDeleteCategoryModal = true" type="button"
|
||||
aria-label="{{ _('loyalty.common.delete') }}"
|
||||
class="text-red-500 hover:text-red-700">
|
||||
<span x-html="$icon('trash', 'w-4 h-4')"></span>
|
||||
|
||||
Reference in New Issue
Block a user