import { athenaConfigOptions } from '../../../global/athena-config.js';
import { addObserverToProducts } from './add-observer-to-products.js';

/**
 * Initial Set URL param for page
 */
function initialUrlParamPageSet() {
    const urlParams = new URLSearchParams(window.location.href);
    const page = urlParams.get('page');

    const products = document.querySelectorAll('.product-item');
    products.forEach((product, index) => {
        product.setAttribute('data-page', page ? page : 1);
    });

    //Adding Observer To Products
    addObserverToProducts(athenaConfigOptions.currentPage);
}

//Exporting all Functions
export {
    initialUrlParamPageSet
}