const updateBtn = document.getElementById("update-button");
const subjectInput = document.getElementById("subject-input");
const responsibilitiesInput = document.getElementById("responsibilities-input");
const dateInput = document.getElementById("date-input");
const dealId = document.getElementById("vb-id").dataset.id;

updateBtn.addEventListener("click", () => {
    if (!correctData()) {
        return;
    }
    if (!validate()) {
        return;
    }
});

const correctData = function () {

    return true;
};

const validate = function () {

    return true;
};

updateBtn.addEventListener("click", () => {
    let dealModel = {
        "Id": parseInt(dealId),
        "Subject": subjectInput.value,
        "Responsibilities": responsibilitiesInput.value,
        "Date": new Date(dateInput.value)
    };
    console.log(dealModel)
    $.ajax({
        url: "/deal/update",
        type: "POST",
        contentType: "application/json",
        data: JSON.stringify(dealModel)
    }).done(() => {
        window.location.href = "/Home/Deals";
    });
});