diff --git a/controller/doctorController.js b/controller/doctorController.js index e7913c3..3ba63b6 100644 --- a/controller/doctorController.js +++ b/controller/doctorController.js @@ -41,3 +41,35 @@ exports.fetchDoctorById = async (req, res) => { .json({ success: false, message: "Internal Server Error" }); } }; + +// Controller function to update doctor profile +exports.updateDoctorProfile = async (req, res) => { + try { + const doctorId = req.params.id; // Assuming the ID is passed as a route parameter + const updates = req.body; // Assuming updates are sent in the request body + + const updatedDoctor = await userDoctor.findOneAndUpdate( + { firebaseUserId: doctorId }, // Find by firebaseUserId + updates, + { new: true } + ); + + if (!updatedDoctor) { + return res + .status(404) + .json({ success: false, message: "Patient not found" }); + } + console.log(updatedDoctor); + + return res.status(200).json({ + success: true, + message: "Doctor profile updated successfully", + data: updatedDoctor, + }); + } catch (err) { + return res + .status(500) + .json({ success: false, message: "Internal Server Error" }); + } +}; + diff --git a/routes/authenticationRoutes.js b/routes/authenticationRoutes.js index 24004f2..4f255e0 100644 --- a/routes/authenticationRoutes.js +++ b/routes/authenticationRoutes.js @@ -12,6 +12,7 @@ const { const { fetchAllDoctors, fetchDoctorById, + updateDoctorProfile } = require("../controller/doctorController"); const { updatePatientProfile } = require("../controller/patientController"); @@ -29,6 +30,7 @@ router.post("/getDoctor", fetchDoctorDetails); router.get("/getAllDoctors", fetchAllDoctors); router.get("/getDoctorById/:id", fetchDoctorById); router.put("/updatePatient/:id", updatePatientProfile); +router.put("/updateDoctor/:id",updateDoctorProfile); //Appointment route router.post("/bookAppointment", bookAppointment);