document.querySelector('[data-sidebar-toggle]')?.addEventListener('click', () => {
    document.getElementById('sidebar')?.classList.toggle('open');
});

document.querySelector('[data-branch-switch]')?.addEventListener('change', (event) => {
    const form = document.querySelector('[data-branch-form]');
    form.action = event.target.value;
    form.submit();
});

document.querySelectorAll('form[data-confirm]').forEach((form) => {
    form.addEventListener('submit', (event) => {
        if (!window.confirm(form.dataset.confirm)) {
            event.preventDefault();
        }
    });
});
