The store and merchant init-alpine.js derive currentPage from the URL's last segment (e.g., /loyalty/program -> 'program'). Loyalty menu items used prefixed IDs like 'loyalty-program' which never matched, so sidebar items never highlighted. Fixed by renaming all store/merchant menu item IDs and JS currentPage values to match URL segments: program, cards, analytics, transactions, pins, settings — consistent with how every other module works. Also reverted the init-alpine.js guard that broke storeCode extraction, and added missing loyalty.common.contact_admin_setup translation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
2.0 KiB
JavaScript
54 lines
2.0 KiB
JavaScript
// 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: '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');
|