feat(loyalty): translatable categories + mandatory on earn points
Some checks failed
Some checks failed
- Add name_translations JSON column to StoreTransactionCategory
(migration loyalty_008). Stores {"en": "Men", "fr": "Hommes", ...}.
Model has get_translated_name(lang) helper.
- Admin CRUD form now has FR/DE/LB translation inputs alongside the
default name.
- Points earn: category_id is now mandatory when the store has
active categories configured. Returns CATEGORY_REQUIRED error.
- Stamps: category remains optional (quick tap workflow).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,7 @@ function adminLoyaltyMerchantDetail() {
|
||||
storeCategories: [],
|
||||
showAddCategory: false,
|
||||
newCategoryName: '',
|
||||
newCategoryTranslations: { fr: '', de: '', lb: '' },
|
||||
|
||||
// State
|
||||
loading: false,
|
||||
@@ -284,11 +285,20 @@ function adminLoyaltyMerchantDetail() {
|
||||
async createCategory() {
|
||||
if (!this.newCategoryName || !this.selectedCategoryStoreId) return;
|
||||
try {
|
||||
// Build translations dict (only include non-empty values)
|
||||
const translations = {};
|
||||
if (this.newCategoryName) translations.en = this.newCategoryName;
|
||||
for (const [lang, val] of Object.entries(this.newCategoryTranslations)) {
|
||||
if (val) translations[lang] = val;
|
||||
}
|
||||
|
||||
await apiClient.post(`/admin/loyalty/stores/${this.selectedCategoryStoreId}/categories`, {
|
||||
name: this.newCategoryName,
|
||||
name_translations: Object.keys(translations).length > 0 ? translations : null,
|
||||
display_order: this.storeCategories.length,
|
||||
});
|
||||
this.newCategoryName = '';
|
||||
this.newCategoryTranslations = { fr: '', de: '', lb: '' };
|
||||
this.showAddCategory = false;
|
||||
await this.loadCategoriesForStore();
|
||||
Utils.showToast('Category created', 'success');
|
||||
|
||||
Reference in New Issue
Block a user