Case_accounting/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Contracts/contract-update.js

42 lines
1.0 KiB
JavaScript

const updateBtn = document.getElementById("update-button");
const serviceInput = document.getElementById("service-input")
const coastInput = document.getElementById("coast-input")
const dateInput = document.getElementById("date-input")
const contractId = document.getElementById("contr-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 contract = {
"Id": parseInt(contractId),
"Service": serviceInput.value,
"Coast": parseFloat(coastInput.value),
"Date": new Date(dateInput.value),
};
console.log(contract)
$.ajax({
url: "/lawyer/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(contract)
}).done(() => {
window.location.href = "/Home/Contracts";
});
});