2023-05-18 23:42:48 +04:00
|
|
|
|
const createBtn = document.getElementById("create-button");
|
|
|
|
|
const serviceInput = document.getElementById("service-input")
|
|
|
|
|
const coastInput = document.getElementById("coast-input")
|
|
|
|
|
const dateInput = document.getElementById("date-input")
|
|
|
|
|
|
|
|
|
|
createBtn.addEventListener("click", () => {
|
|
|
|
|
if (!correctData()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!validate()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const correctData = function () {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const validate = function () {
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
createBtn.addEventListener("click", () => {
|
|
|
|
|
let contract = {
|
|
|
|
|
"Service": serviceInput.value,
|
|
|
|
|
"Coast": parseFloat(coastInput.value),
|
|
|
|
|
"Date": new Date(dateInput.value),
|
|
|
|
|
};
|
|
|
|
|
console.log(contract)
|
|
|
|
|
$.ajax({
|
2023-05-19 13:20:14 +04:00
|
|
|
|
url: "/contracts/create",
|
2023-05-18 23:42:48 +04:00
|
|
|
|
type: "POST",
|
|
|
|
|
contentType: "application/json",
|
|
|
|
|
data: JSON.stringify(contract)
|
|
|
|
|
}).done(() => {
|
|
|
|
|
window.location.href = "/Home/Contracts";
|
|
|
|
|
});
|
|
|
|
|
});
|