import { handleHtml } from '../../global/helpers/athena-global-helper.js';

function appendBreadcrumbsandCategoryName(breadcrumbs, categoryName, isCategory){
    let breadCrumbsContainer = document.querySelector('.breadcrumbs-container');
    let categoryNameContainer = document.querySelector('.category-name-container');


    if(breadCrumbsContainer){
        if(isCategory){
            breadCrumbsContainer.innerHTML = '';
            breadCrumbsContainer.append(
                handleHtml(`
                    <span class="breadcrumbs-item">
                        Home > ${breadcrumbs}
                    </span>
                `, `.breadcrumbs-item`)
            );
        }else{
            breadCrumbsContainer.classList.add('hide-breadcrumbs')
        }
    }

    if(categoryNameContainer){
        if(isCategory){
            categoryNameContainer.innerHTML = '';
            categoryNameContainer.append(
                handleHtml(`
                    <span class="category-name-item">
                        ${categoryName}
                    </span>
                `, `.category-name-item`)
            );
        }else{
            categoryNameContainer.classList.add('hide-category-name-item')
        }
    }

}

export {
    appendBreadcrumbsandCategoryName
}