Skip to content

Commit

Permalink
#2 wireup back button from student edit && finish edit student functi…
Browse files Browse the repository at this point in the history
…onality
  • Loading branch information
MirTalpur committed Aug 29, 2020
1 parent 9d66ab1 commit 1033827
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion components/individualStudentTeacherEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default class TeacherEditStudentComponent extends React.Component {

backButtonComponent = () => {
return(
<Button style={{ float: 'left' }}>
<Button style={{ float: 'left' }} onClick={(e) => this.props.handleIndividualStudentTeacherBackClicked(e)}>
Back
</Button>
)
Expand Down
1 change: 1 addition & 0 deletions components/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export default class Nav extends React.Component {
onBlurhandleIndividualStudentTeacherEditPasswordChange={this.props.onBlurhandleIndividualStudentTeacherEditPasswordChange}
handleIndividualStudentTeacherEditImageChange={this.props.handleIndividualStudentTeacherEditImageChange}
handleIndividualStudentTeacherUpload={this.props.handleIndividualStudentTeacherUpload}
handleIndividualStudentTeacherBackClicked={this.props.handleIndividualStudentTeacherBackClicked}
/>
}
}
Expand Down
52 changes: 31 additions & 21 deletions components/teacherDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class TeacherDashboard extends React.Component {
this.onBlurhandleIndividualStudentTeacherEditPasswordChange = this.onBlurhandleIndividualStudentTeacherEditPasswordChange.bind(this);
this.handleIndividualStudentTeacherEditImageChange = this.handleIndividualStudentTeacherEditImageChange.bind(this);
this.handleIndividualStudentTeacherUpload = this.handleIndividualStudentTeacherUpload.bind(this);
this.handleIndividualStudentTeacherBackClicked = this.handleIndividualStudentTeacherBackClicked.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -394,9 +395,9 @@ export class TeacherDashboard extends React.Component {
email: email,
password: this.state.teacherStudentComponent.individualStudentTeacherEditPassword,
}).then(result => {
updateCalls -= 1;
if(updateCalls === 0){
this.handleUpdateOnStudent();
updateCalls -= 2;
if(updateCalls <= 0){
this.props.handleUpdateOnStudent();
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
Expand All @@ -405,7 +406,7 @@ export class TeacherDashboard extends React.Component {
}
}));
}
console.log('update sucessful for email and password as teacher' + result);
console.log('update sucessful for email or password as teacher' + result);
}).catch(err => {
console.log(err)
})
Expand All @@ -419,7 +420,7 @@ export class TeacherDashboard extends React.Component {
}).then(result => {
console.log('update sucessfully updateStudentProfilePicAsTeacher: ' + JSON.stringify(result));
updateCalls -= 1;
if(updateCalls === 0){
if(updateCalls <= 0){
this.props.handleUpdateOnStudent();
this.setState(prevState => ({
teacherStudentComponent: {
Expand All @@ -444,6 +445,17 @@ export class TeacherDashboard extends React.Component {
requireStudentGradeUpdate: requireStudentGradeUpdate,
}).then(result => {
console.log('update sucessfully updateStudentNameGradeAsTeacher: ' + JSON.stringify(result));
updateCalls -= 2;
if(updateCalls === 0){
this.props.handleUpdateOnStudent();
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentTeacherEditUpdateButtonLoading: false,
individualStudentEditClicked: false,
}
}));
}
}).catch(err => {
console.log(err)
});
Expand All @@ -458,6 +470,19 @@ export class TeacherDashboard extends React.Component {
}
}
/* Update Button End */

/* Back Button */
handleIndividualStudentTeacherBackClicked = (e) => {
e.preventDefault();
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
individualStudentEditClicked: false,
}
}));
}

/* Back Button End */
/* individualStudentTeacherEdit component functions end */

/* teacherStudentComponent functions */
Expand All @@ -483,22 +508,6 @@ export class TeacherDashboard extends React.Component {
}));
}
});
// const getStudentDocumentAsTeacher = functions.httpsCallable('getStudentDocumentAsTeacher');
// getStudentDocumentAsTeacher({
// uid: this.state.currentUserDoc.uid,
// studentUid: e.uid,
// }).then(result => {
// this.setState(prevState => ({
// teacherStudentComponent: {
// ...prevState.teacherStudentComponent,
// individualStudentEditClicked: true,
// individualEditStudentInformation: result,
// individualStudentEditLoading: false,
// }
// }));
// }).catch(err => {
// console.log(err)
// });
}

/* teacherStudentComponent functions end */
Expand Down Expand Up @@ -751,6 +760,7 @@ export class TeacherDashboard extends React.Component {
onBlurhandleIndividualStudentTeacherEditPasswordChange={this.onBlurhandleIndividualStudentTeacherEditPasswordChange}
handleIndividualStudentTeacherEditImageChange={this.handleIndividualStudentTeacherEditImageChange}
handleIndividualStudentTeacherUpload={this.handleIndividualStudentTeacherUpload}
handleIndividualStudentTeacherBackClicked={this.handleIndividualStudentTeacherBackClicked}
/>
</div>
</React.Fragment>
Expand Down
1 change: 1 addition & 0 deletions components/teacherStudentComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default class TeacherStudentComponent extends React.Component {
onBlurhandleIndividualStudentTeacherEditPasswordChange={this.props.onBlurhandleIndividualStudentTeacherEditPasswordChange}
handleIndividualStudentTeacherEditImageChange={this.props.handleIndividualStudentTeacherEditImageChange}
handleIndividualStudentTeacherUpload={this.props.handleIndividualStudentTeacherUpload}
handleIndividualStudentTeacherBackClicked={this.props.handleIndividualStudentTeacherBackClicked}
/>
// displayName: "asdlkfj 89234"
// email: "alskdjf@gmail.com"
Expand Down

0 comments on commit 1033827

Please sign in to comment.