import './bootstrap';

// Inicializar todos los dropdowns de Bootstrap 5
document.addEventListener('DOMContentLoaded', function() {
    // Inicializar dropdowns
    const dropdownElementList = document.querySelectorAll('[data-bs-toggle="dropdown"]');
    
    dropdownElementList.forEach(function(dropdownToggleEl) {
        new bootstrap.Dropdown(dropdownToggleEl);
    });

    const updateButton = document.querySelector('a[name="update-data-button"]');
    const loadingOverlay = document.getElementById('loadingOverlay');

    if (updateButton && loadingOverlay) {
        updateButton.addEventListener('click', function(event) {
            event.preventDefault(); 
            loadingOverlay.style.display = 'flex';

            setTimeout(() => {
                window.location.href = updateButton.href;
            }, 50);
        });
    }
});
