feat(loyalty): cross-persona page alignment with shared components

Align loyalty pages across admin, merchant, and store personas so each
sees the same page set scoped to their access level. Admin acts as a
superset of merchant with "on behalf" capabilities.

New pages:
- Store: Staff PINs management (CRUD)
- Merchant: Cards, Card Detail, Transactions, Staff PINs (CRUD), Settings (read-only)
- Admin: Merchant Cards, Card Detail, Transactions, PINs (read-only)

Architecture:
- 4 shared Jinja2 partials (cards-list, card-detail, transactions, pins)
- 4 shared JS factory modules parameterized by apiPrefix/scope
- Persona templates are thin wrappers including shared partials
- PinDetailResponse schema for cross-store PIN listings

API: 17 new endpoints (11 merchant, 6 admin on-behalf)
Tests: 38 new integration tests, arch-check green
i18n: ~130 new keys across en/fr/de/lb
Docs: pages-and-navigation.md with full page matrix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-22 19:28:07 +01:00
parent f41f72b86f
commit 6161d69ba2
49 changed files with 4385 additions and 14 deletions

View File

@@ -0,0 +1,17 @@
// app/modules/loyalty/static/merchant/js/loyalty-card-detail.js
// noqa: js-006 - async init pattern is safe, loadData has try/catch
const merchantCardDetailLog = window.LogConfig.loggers.merchantCardDetail || window.LogConfig.createLogger('merchantCardDetail');
function merchantLoyaltyCardDetail() {
return loyaltyCardDetailView({
apiPrefix: '/merchants/loyalty',
backUrl: '/merchants/loyalty/cards',
currentPage: 'loyalty-cards',
});
}
if (!window.LogConfig.loggers.merchantCardDetail) {
window.LogConfig.loggers.merchantCardDetail = window.LogConfig.createLogger('merchantCardDetail');
}
merchantCardDetailLog.info('Merchant loyalty card detail module loaded');

View File

@@ -0,0 +1,18 @@
// app/modules/loyalty/static/merchant/js/loyalty-cards.js
// noqa: js-006 - async init pattern is safe, loadData has try/catch
const merchantCardsLog = window.LogConfig.loggers.merchantCards || window.LogConfig.createLogger('merchantCards');
function merchantLoyaltyCards() {
return loyaltyCardsList({
apiPrefix: '/merchants/loyalty',
baseUrl: '/merchants/loyalty/cards',
showStoreFilter: true,
currentPage: 'loyalty-cards',
});
}
if (!window.LogConfig.loggers.merchantCards) {
window.LogConfig.loggers.merchantCards = window.LogConfig.createLogger('merchantCards');
}
merchantCardsLog.info('Merchant loyalty cards module loaded');

View File

@@ -0,0 +1,53 @@
// app/modules/loyalty/static/merchant/js/loyalty-merchant-settings.js
// noqa: js-006 - async init pattern is safe, loadData has try/catch
const merchantSettingsViewLog = window.LogConfig.loggers.merchantSettingsView || window.LogConfig.createLogger('merchantSettingsView');
function merchantLoyaltyMerchantSettings() {
return {
...data(),
currentPage: 'loyalty-settings',
settings: null,
loading: false,
error: null,
async init() {
merchantSettingsViewLog.info('=== MERCHANT LOYALTY SETTINGS VIEW PAGE INITIALIZING ===');
if (window._merchantLoyaltyMerchantSettingsInitialized) return;
window._merchantLoyaltyMerchantSettingsInitialized = true;
this.loadMenuConfig();
await this.loadSettings();
merchantSettingsViewLog.info('=== MERCHANT LOYALTY SETTINGS VIEW PAGE INITIALIZATION COMPLETE ===');
},
async loadSettings() {
this.loading = true;
this.error = null;
try {
const response = await apiClient.get('/merchants/loyalty/settings');
if (response) {
this.settings = response;
merchantSettingsViewLog.info('Settings loaded');
}
} catch (error) {
if (error.status === 404) {
merchantSettingsViewLog.info('No settings found');
this.settings = null;
} else {
merchantSettingsViewLog.error('Failed to load settings:', error);
this.error = error.message || 'Failed to load settings';
}
} finally {
this.loading = false;
}
},
};
}
if (!window.LogConfig.loggers.merchantSettingsView) {
window.LogConfig.loggers.merchantSettingsView = window.LogConfig.createLogger('merchantSettingsView');
}
merchantSettingsViewLog.info('Merchant loyalty settings view module loaded');

View File

@@ -0,0 +1,18 @@
// app/modules/loyalty/static/merchant/js/loyalty-pins.js
// noqa: js-006 - async init pattern is safe, loadData has try/catch
const merchantPinsLog = window.LogConfig.loggers.merchantPins || window.LogConfig.createLogger('merchantPins');
function merchantLoyaltyPins() {
return loyaltyPinsList({
apiPrefix: '/merchants/loyalty',
showStoreFilter: true,
showCrud: true,
currentPage: 'loyalty-pins',
});
}
if (!window.LogConfig.loggers.merchantPins) {
window.LogConfig.loggers.merchantPins = window.LogConfig.createLogger('merchantPins');
}
merchantPinsLog.info('Merchant loyalty pins module loaded');

View File

@@ -0,0 +1,17 @@
// app/modules/loyalty/static/merchant/js/loyalty-transactions.js
// noqa: js-006 - async init pattern is safe, loadData has try/catch
const merchantTransactionsLog = window.LogConfig.loggers.merchantTransactions || window.LogConfig.createLogger('merchantTransactions');
function merchantLoyaltyTransactions() {
return loyaltyTransactionsList({
apiPrefix: '/merchants/loyalty',
showStoreFilter: true,
currentPage: 'loyalty-transactions',
});
}
if (!window.LogConfig.loggers.merchantTransactions) {
window.LogConfig.loggers.merchantTransactions = window.LogConfig.createLogger('merchantTransactions');
}
merchantTransactionsLog.info('Merchant loyalty transactions module loaded');