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

    course.request((form) => {
        const formCurrent = $(`#${form.id}`),
            formAction = form.action,
            formMethod = form.method

        $.ajax({
            url: formAction,
            type: formMethod,
            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 () {},
        })
    })

    feedback.request((form) => {
        const formCurrent = $(`#${form.id}`),
            formAction = form.action,
            formMethod = form.method

        $.ajax({
            url: formAction,
            type: formMethod,
            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 () {},
        })
    })
}
