export const prevent = () => {
    let preventModal = document.querySelector('.prevent-modal-wrap');
    let confirmationLink = preventModal.querySelector(':scope .preventModalConfirmationLink');
    let preventModalLabel = preventModal.querySelector(':scope #preventModalLabel');

    // Show modal & populate link
    let preventLinks = document.querySelectorAll('.prevent');
    preventLinks.forEach((preventLink) => {
        preventLink.addEventListener('click', function (e) {
            e.preventDefault();
            confirmationLink.setAttribute('href', preventLink.getAttribute('href'));

            // set trigger btn html (or data-prevent-content value) as confirm btn label
            confirmationLink.textContent = preventLink.textContent;
            let preventContent = preventLink.getAttribute('data-prevent-content');
            if (preventContent) {
                preventModalLabel.textContent = preventContent;
            }
            
            preventModal.aaBootstrapModal.show();
        });
    });

    // reset modal
    preventModal.addEventListener('hide.bs.modal', function (e) {
        confirmationLink.href = '#';
        confirmationLink.textContent = confirmationLink.getAttribute('data-default-label');
        preventModalLabel.textContent = preventModalLabel.getAttribute('data-default-label');
    });
};