// app/modules/loyalty/static/admin/js/loyalty-merchant-devices.js
const adminMerchantDevicesLog = window.LogConfig.loggers.adminMerchantDevices || window.LogConfig.createLogger('adminMerchantDevices');

function adminMerchantDevices() {
    const merchantId = document.body.dataset.merchantId
        || (window.location.pathname.match(/\/merchants\/(\d+)/) || [])[1];
    if (!merchantId) {
        adminMerchantDevicesLog.error('Could not determine merchant_id from URL');
    }
    return loyaltyDevicesList({
        apiPrefix: '/admin/loyalty/merchants/' + merchantId,
        // Admin reuses the merchant locations endpoint for the store dropdown.
        locationsApiPrefix: '/admin/loyalty/merchants/' + merchantId,
        showStoreFilter: true,
        showCrud: true,
        currentPage: 'admin-merchant-devices',
    });
}

if (!window.LogConfig.loggers.adminMerchantDevices) {
    window.LogConfig.loggers.adminMerchantDevices = window.LogConfig.createLogger('adminMerchantDevices');
}
adminMerchantDevicesLog.info('Admin merchant devices module loaded');
