Skip to content

Commit 5c62af2

Browse files
Teacher profile update added
1 parent ebf9223 commit 5c62af2

4 files changed

Lines changed: 279 additions & 311 deletions

File tree

Backend/Controllers/Teacher/controller.tprofile.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const updateProfileById = async (req, res) => {
4545
}
4646
const update = await Profile.findByIdAndUpdate(id, updateProfile)
4747
.then(() => {
48-
res.status(200).send({status: "Teacher Profile Updated"})
48+
res.status(200).send({status: "Teacher Profile status Updated"})
4949
}).catch((err) => {
5050
console.log(err);
5151
res.status(500).send({status: " Error", error:err.message});
@@ -58,10 +58,21 @@ const deleteProfileById = async (req, res) => {
5858
res.send('Teacher Profile Deleted');
5959
}
6060

61+
const updateById = async(req, res) => {
62+
const { slug } = req.params
63+
const {registrationNumber, fName, lName, nic, passportNumber, address, contactNumber, email, password, editedDate} = req.body
64+
Profile.findOneAndUpdate({slug}, {registrationNumber, fName, lName, nic, passportNumber, address, contactNumber, email, password, editedDate}, {new: true})
65+
.exec((err,topic) => {
66+
if(err) console.log(err)
67+
res.json(topic);
68+
})
69+
};
70+
6171
module.exports = {
6272
createProfile,
6373
getAllProfiles,
6474
viewProfileById,
6575
updateProfileById,
66-
deleteProfileById
76+
deleteProfileById,
77+
updateById
6778
}

Backend/Routes/Teacher/route.tprofile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = function () {
77
router.get('/', controller.getAllProfiles);
88
router.get('/viewbyid/:id', controller.viewProfileById);
99
router.put('/update/:id', controller.updateProfileById);
10+
router.put('/update-all/:id', controller.updateById);
1011
router.delete('/delete/:id', controller.deleteProfileById);
1112
return router;
1213
}

frontend/src/Routes/pageRoutes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import ViewPendingTeachers from "../Supervisor/viewPendingTeachers";
5555
import CreateMaterial from "../Teacher/createMaterial";
5656
import ViewUploadedMaterials from "../Teacher/viewUploadedMaterials";
5757
import supervisorDashboard from "../Supervisor/supervisorDashboard";
58+
import UpdateTeacherProfile from "../Teacher/updateTeacherProfile";
5859

5960
import teacherTaskUpdate from "../Class/teacherUpdate";
6061
import teacherTask from "../Class/teacher";
@@ -104,6 +105,7 @@ function PageRoutes() {
104105
<Route path="/accountant/report" component={ReactPDF}/>
105106
<Route path="/accountant/" component={AccountantDashboard}/>
106107

108+
<Route path="/teacher/profile/update/:id" component={UpdateTeacherProfile}/>
107109
<Route path="/teacher/registration" component={TeacherRegistration}/>
108110
<Route path="/teacher/profile" component={TeacherProfile}/>
109111
<Route path="/teacher/view-registration" component={ViewTeacherRegistration}/>

0 commit comments

Comments
 (0)