// app/modules/loyalty/static/admin/js/loyalty-merchant-cards.js
// Admin wrapper for shared loyalty cards list (on-behalf view).

const adminMerchantCardsLog = window.LogConfig.loggers.adminMerchantCards || window.LogConfig.createLogger('adminMerchantCards');

function adminMerchantCards() {
    // Extract merchant_id from URL: /admin/loyalty/merchants/{merchant_id}/cards
    const pathParts = window.location.pathname.split('/');
    const merchantsIndex = pathParts.indexOf('merchants');
    const merchantId = merchantsIndex !== -1 ? pathParts[merchantsIndex + 1] : null;

    return loyaltyCardsList({
        apiPrefix: '/admin/loyalty/merchants/' + merchantId,
        baseUrl: '/admin/loyalty/merchants/' + merchantId + '/cards',
        showStoreFilter: true,
        currentPage: 'loyalty-programs',
    });
}

if (!window.LogConfig.loggers.adminMerchantCards) {
    window.LogConfig.loggers.adminMerchantCards = window.LogConfig.createLogger('adminMerchantCards');
}
adminMerchantCardsLog.info('Admin merchant cards module loaded');
