গত মডিউলে আমরা মোডাল নিয়ে কাজ করেছি।মোডালের Take Appointment বাটনে ক্লিক করলে Appointment টি প্রসেস করার কাজটি এই মডিউলে করা হবে।
...
...
...
const handleAppointment = () => {
const param = new URLSearchParams(window.location.search).get("doctorId");
const status = document.getElementsByName("status");
const selected = Array.from(status).find((button) => button.checked);
const symptom = document.getElementById("symptom").value;
const time = document.getElementById("time-container");
const selectedTime = time.options[time.selectedIndex];
const patient_id = localStorage.getItem("patient_id");
const info = {
appointment_type: selected.value,
appointment_status: "Pending",
time: selectedTime.value,
symptom: symptom,
cancel: false,
patient: patient_id,
doctor: param,
};
console.log(info);
fetch("https://testing-8az5.onrender.com/appointment/", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(info),
})
.then((res) => res.json())
.then((data) => {
window.location.href = `pdf.html?doctorId=${param}`;
// handlePdf();
// console.log(data);
});
};
const loadPatientId = () => {
const user_id = localStorage.getItem("user_id");
fetch(`https://testing-8az5.onrender.com/patient/list/?user_id=${user_id}`)
.then((res) => res.json())
.then((data) => {
localStorage.setItem("patient_id", data[0].id);
});
};
...
...
...