const toastr = require('toastr');

toastr.options = {
    "closeButton": true,
    "debug": false,
    "newestOnTop": true,
    "progressBar": true,
    "positionClass": "toast-bottom-right",
    "preventDuplicates": false,
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": "10000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
};

export const flashbagNotification = ($) => {
    let container = $('#toastContainerBuilder');
    let notifications = container.find('gda-error-node');

    // Parse notifications
    for (let i = 0; i < notifications.length; i++) {
        let level = notifications[i].getAttribute('data-level');
        let message = notifications[i].getAttribute('data-message');

        toastr[level](message);
    }

    // Clear container
    container.html('');
};