export const form = () => {
    let resume = new Validations('#resume')

    resume.request((form) => {
        const formCurrent = $(`#${form.id}`)

        let resumeForm = document.querySelector("#resume");
        let formData = new FormData(resumeForm);

        $.ajax({
            url: formCurrent.attr('action'),
            type: formCurrent.attr('method'),
            data: formData,
            contentType: false,
            processData: false,
            beforeSend: function () {
                new CreatePreloader(form.id)
            },
            success: function (response) {
                new RemovePreloader(form.id, response.message, response.status)
            },
            error: function (response) {
                new RemovePreloader(form.id, response.statusText + ' ' + response.responseText, response.status)
            },
            complete: function () {},
        })
    })

    //
    let feedbackForm = new Validations('#feedback')

    feedbackForm.request((form) => {
        const formCurrent = $(`#${form.id}`)

        $.ajax({
            url: formCurrent.attr('action'),
            type: formCurrent.attr('method'),
            data: formCurrent.serialize(),
            beforeSend: function () {
                new CreatePreloader(form.id)
            },
            success: function (response) {
                new RemovePreloader(form.id, response.message, response.status)
            },
            error: function (response) {
                new RemovePreloader(form.id, response.statusText + ' ' + response.responseText, response.status)
            },
            complete: function () {},
        })
    })

    //
    let tenderForm = new Validations('#tender')

    tenderForm.request((form) => {
        const formCurrent = $(`#${form.id}`)

        $.ajax({
            url: formCurrent.attr('action'),
            type: formCurrent.attr('method'),
            data: formCurrent.serialize(),
            beforeSend: function () {
                new CreatePreloader(form.id)
            },
            success: function (response) {
                new RemovePreloader(form.id, response.message, response.status)
            },
            error: function (response) {
                new RemovePreloader(form.id, response.statusText + ' ' + response.responseText, response.status)
            },
            complete: function () {},
        })
    })
}
