Skip to content

Commit

Permalink
(Task #2): update state with edit student from teacher profile
Browse files Browse the repository at this point in the history
  • Loading branch information
MirTalpur committed Jun 7, 2020
1 parent 0ea9d27 commit 41f2620
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion components/teacherDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class TeacherDashboard extends React.Component {
},
teacherStudentComponent: {
currentUserDoc: this.props.currentUserDoc,
individualStudentEditClicked: false,
individualEditStudentInformation: null,
},
}
this.handleMenuClick = this.handleMenuClick.bind(this);
Expand All @@ -50,11 +52,31 @@ export class TeacherDashboard extends React.Component {
console.log(this.state.teacherStudentComponent.currentUserDoc);
}

/* teacherStudentComponent functions */
teacherStudentComponentHandleTeacherStudentClick = (e) => {
console.log("im in teacherStudentComponentHandleTeacherStudentClick..")
console.log(e);
console.log("studentUid: " + e.uid);
console.log("uid: " + this.state.currentUserDoc.uid);
const getStudentDocumentAsTeacher = functions.httpsCallable('getStudentDocumentAsTeacher');
getStudentDocumentAsTeacher({
uid: this.state.currentUserDoc.uid,
studentUid: e.uid,
}).then(result => {
console.log(result);
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentEditClicked: true,
individualEditStudentInformation: result
}
}));
}).catch(err => {
console.log(err)
})
}

/* teacherStudentComponent functions end */

/* Student attendance functions */
handleStudentAttendanceDateRange = (dates, dateStrings) => {
console.log("in date handleStudentAttendanceDateRange");
Expand Down
1 change: 1 addition & 0 deletions components/teacherStudentComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class TeacherStudentComponent extends React.Component {
showStudentsComponent = (context) => {
console.log("in teacherStudentComponent");
console.log(this.props.teacherStudentComponent.currentUserDoc);
// check if the individualStudentEditClicked is clicked
if(this.props.teacherStudentComponent.currentUserDoc && this.props.teacherStudentComponent.currentUserDoc.teacherStudents){
return(
<List style={{position: "absolute"}}>
Expand Down

0 comments on commit 41f2620

Please sign in to comment.