feat(loyalty): inline edit for transaction categories in admin
Some checks failed
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has started running
CI / ruff (push) Successful in 21s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled

Category list now has a pencil edit button that expands inline with
name + FR/DE/LB translation fields. Save updates via PATCH API.
View mode shows translations summary next to the name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-19 19:27:55 +02:00
parent eafa086c73
commit 51bcc9f874
2 changed files with 95 additions and 15 deletions

View File

@@ -39,6 +39,8 @@ function adminLoyaltyMerchantDetail() {
showAddCategory: false,
newCategoryName: '',
newCategoryTranslations: { fr: '', de: '', lb: '' },
editingCategoryId: null,
editCategoryData: { name: '', translations: { fr: '', de: '', lb: '' } },
// State
loading: false,
@@ -307,6 +309,38 @@ function adminLoyaltyMerchantDetail() {
}
},
startEditCategory(cat) {
this.editingCategoryId = cat.id;
this.editCategoryData = {
name: cat.name,
translations: {
fr: cat.name_translations?.fr || '',
de: cat.name_translations?.de || '',
lb: cat.name_translations?.lb || '',
},
};
},
async saveEditCategory(catId) {
if (!this.editCategoryData.name) return;
try {
const translations = { en: this.editCategoryData.name };
for (const [lang, val] of Object.entries(this.editCategoryData.translations)) {
if (val) translations[lang] = val;
}
await apiClient.patch(`/admin/loyalty/stores/${this.selectedCategoryStoreId}/categories/${catId}`, {
name: this.editCategoryData.name,
name_translations: Object.keys(translations).length > 0 ? translations : null,
});
this.editingCategoryId = null;
await this.loadCategoriesForStore();
Utils.showToast('Category updated', 'success');
} catch (error) {
Utils.showToast(error.message || 'Failed to update category', 'error');
}
},
async toggleCategoryActive(cat) {
try {
await apiClient.patch(`/admin/loyalty/stores/${this.selectedCategoryStoreId}/categories/${cat.id}`, {