fix(loyalty): use confirm modal for category deletion
Some checks failed
CI / ruff (push) Successful in 17s
CI / pytest (push) Failing after 2h21m18s
CI / validate (push) Successful in 29s
CI / dependency-scanning (push) Successful in 33s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

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:
2026-04-25 14:40:29 +02:00
parent 255ac6525e
commit 56c94ac2f4
3 changed files with 23 additions and 5 deletions

View File

@@ -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;
}
}
};