Skip to content

Commit

Permalink
Merge pull request #25 from ShubhaMahobia/24-implement-update-profile…
Browse files Browse the repository at this point in the history
…-function-for-doctor

 "Add doctor profile update function in doctorController and correspo…
  • Loading branch information
archikirar30 authored Apr 7, 2024
2 parents 9b79886 + 960465a commit 6dd51fd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions controller/doctorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}
};

2 changes: 2 additions & 0 deletions routes/authenticationRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
const {
fetchAllDoctors,
fetchDoctorById,
updateDoctorProfile
} = require("../controller/doctorController");

const { updatePatientProfile } = require("../controller/patientController");
Expand All @@ -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);
Expand Down

0 comments on commit 6dd51fd

Please sign in to comment.