export const redirectionsImport = () => {
    initImportFileNamePreview();
};

function initImportFileNamePreview() {
    var inputs = document.querySelectorAll('input[type="file"][data-file-name-target]');
    if (!inputs || inputs.length === 0) {
        return;
    }

    inputs.forEach(function (input) {
        var targetSelector = input.getAttribute('data-file-name-target');
        if (!targetSelector) {
            return;
        }

        var target = document.querySelector(targetSelector);
        if (!target) {
            return;
        }

        input.addEventListener('change', function () {
            target.textContent = (input.files && input.files.length > 0) ? input.files[0].name : 'Aucun';
        });
    });
}
