feat(loyalty): inline edit for transaction categories in admin
Some checks failed
Some checks failed
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:
@@ -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}`, {
|
||||
|
||||
Reference in New Issue
Block a user