feat(loyalty): translatable categories + mandatory on earn points
Some checks failed
CI / pytest (push) Failing after 2h47m45s
CI / validate (push) Successful in 39s
CI / dependency-scanning (push) Successful in 47s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped
CI / ruff (push) Successful in 21s

- 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:
2026-04-19 14:12:55 +02:00
parent ab2daf99bd
commit eafa086c73
6 changed files with 101 additions and 9 deletions

View File

@@ -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');