[go: nahoru, domu]

Skip to content

Commit

Permalink
#2 implement serverside check on add student
Browse files Browse the repository at this point in the history
  • Loading branch information
MirTalpur committed Aug 29, 2020
1 parent 41f0fd3 commit cc3da61
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
17 changes: 16 additions & 1 deletion components/teacherDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class TeacherDashboard extends React.Component {
teacherStudentAddStudentLoginRequired: false,
teacherStudentAddSubmitLoading: false,
teacherStudentAddSubmitBackendError: false,
handleSubmitTeacherStudentAddBackendError: false,
},
}
this.handleMenuClick = this.handleMenuClick.bind(this);
Expand Down Expand Up @@ -708,7 +709,14 @@ export class TeacherDashboard extends React.Component {
}
}));
}).catch(err => {
console.log(err)
console.log(err);
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
teacherStudentAddSubmitLoading: false,
handleSubmitTeacherStudentAddBackendError: true,
}
}));
});
} else {
console.log("Call backend API not requiring login portal for student");
Expand All @@ -729,6 +737,13 @@ export class TeacherDashboard extends React.Component {
}));
}).catch(err => {
console.log(err)
this.setState(prevState => ({
teacherStudentComponent: {
...prevState.teacherStudentComponent,
teacherStudentAddSubmitLoading: false,
handleSubmitTeacherStudentAddBackendError: true,
}
}));
});
}
}
Expand Down
13 changes: 12 additions & 1 deletion components/teacherStudentAdd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Modal, Button, Form, Space, Input, Switch, Avatar, Upload } from 'antd';
import { Modal, Button, Form, Space, Input, Switch, Avatar, Upload, Alert } from 'antd';

import stylesheet from 'antd/dist/antd.min.css';
import { UploadOutlined, UserOutlined } from '@ant-design/icons';
Expand Down Expand Up @@ -171,6 +171,16 @@ export default class TeacherStudentAdd extends React.Component {
)
}

addBackendError = () => {
if(this.props.teacherStudentComponent.handleSubmitTeacherStudentAddBackendError == true){
return(
<div>
<Alert message="Something went wrong on our end" type="error" />
</div>
)
}
}

render() {
return (
<React.Fragment>
Expand All @@ -191,6 +201,7 @@ export default class TeacherStudentAdd extends React.Component {
]}
>
<Form name="student_information">
{this.addBackendError()}
<Space/>
<Space/>
{this.nameComponent()}
Expand Down

0 comments on commit cc3da61

Please sign in to comment.