import { athenaConfig, athenaConfigOptions } from '../../global/athena-config.js';
import { handleHtml } from '../../global/helpers/athena-global-helper.js';

/**
 * Append Amount
 *
 * @param amount
 */
function appendAmount(amount) {
    if(amount && amount.from != null && amount.to != null){
        athenaConfigOptions.searchAmount.innerHTML = '';
        athenaConfigOptions.searchAmount.append(
            handleHtml(`
                <div class="athena-search-amount-inner hide-amount">
                    <span class="amount-text">Items</span>
                    <span>${amount.from}</span> 
                    <span>-</span>  
                    <span>${amount.to}</span>
                    <span>of</span>
                    <span class="total-amount">${new Intl.NumberFormat().format(amount.total)}</span>
                </div>
            `, '.athena-search-amount-inner')
        )

        let amountContainer = document.querySelector('.athena-search-amount-inner');
        if(athenaConfig.InfiniteScrollStatus) {
            amountContainer?.classList.add('infinite-scroll-amount');
        }
        amountContainer?.classList.remove('hide-amount');
    }else if(amount && amount.from == null && amount.to == null){
        athenaConfigOptions.searchAmount.innerHTML = '';
    }
}

//Exporting all Functions
export {
    appendAmount
}