"use strict";

$(document).on('submit', '#setting-form', function (e) {
    e.preventDefault();
    let form = $(this)[0];
    let url = $(this).attr('action')
    let formData = new FormData(form);     
        $.ajax({
            url:url,
            type: "post", 
            contentType: false,
            processData: false,
            data: formData, 
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            success: function(response) {
                $('#loader').hide();
                var json = JSON.parse(JSON.stringify(response));
                if (typeof response == 'object') {
                    if (json.status == "Yes") {
                        window.location = baseURL;
                    } else {
                        Snackbar.show({ text: 'Your OTP Code was wrong, Please try again', pos: 'bottom-center' });
                    }
                } else {
                    Snackbar.show({ text: 'Your OTP Code was wrong, Please try again', pos: 'bottom-center' });

                }
            },
            error: function(jqXHR, textStatus, exception) {
                $('#loader').hide();
            }
        });   
});