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

const adminMerchantPinsLog = window.LogConfig.loggers.adminMerchantPins || window.LogConfig.createLogger('adminMerchantPins');

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

    return loyaltyPinsList({
        apiPrefix: '/admin/loyalty/merchants/' + merchantId,
        showStoreFilter: true,
        showCrud: false,
        currentPage: 'loyalty-programs',
    });
}

if (!window.LogConfig.loggers.adminMerchantPins) {
    window.LogConfig.loggers.adminMerchantPins = window.LogConfig.createLogger('adminMerchantPins');
}
adminMerchantPinsLog.info('Admin merchant pins module loaded');
