//jshint esversion: 6

$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});

$(document).on("submit","#contact-formData", function(e){

    e.preventDefault();
    $(".send-data").hide();
    $(".sending-data").show();


    $.ajax({
        url: '/landing/contact/form',
        type: 'POST',
        data: $("#contact-formData").serialize(),
        success: function(response) {

            // console.log(response);

            setTimeout(()=>{
                if(response.status === 'success'){

                    message = '<div class="alert alert-success">MAIL RECEIVED. WE WILL GET BACK TO YOU</div>';

                }else{

                    message = '<div class="alert alert-danger">UNABLE TO SEND MAIL AT THE MOMENT. TRY LATER</div>';
                }

                $(".mail_response").html(message);
                $(".mail_response").show();


                $(".sending-data").hide();
                $(".send-data").show();

            },1);
        },
        error: function(response){
            // console.log(response);
        }
    });

});


$(document).on("submit","#apply-form", function(e){

    e.preventDefault();
    $(".send-data").hide();
    $(".sending-data").show();


    $.ajax({
        url: '/landing/contact/form',
        type: 'POST',
        data: $("#apply-form").serialize(),
        success: function(response) {

            console.log(response);

            setTimeout(()=>{
                $(".sending-data").hide();
                $(".send-data").show();

            },1000);
        },
        error: function(response){
            console.log(response);
        }
    });

    setTimeout(()=>{
        $(".sending-data").hide();
        $(".send-data").show();

    },1000);


});
