Skip to content

Commit

Permalink
feat: show loader when fetching app instance resources
Browse files Browse the repository at this point in the history
closes #10
  • Loading branch information
juancarlosfarah committed May 21, 2019
1 parent 5d3636e commit 516e436
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/modes/teacher/TeacherMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ import TeacherView from './TeacherView';
import TeacherDashboard from './TeacherDashboard';
import { DEFAULT_VIEW, DASHBOARD_VIEW } from '../../../config/views';
import { getAppInstanceResources } from '../../../actions';
import Loader from '../../common/Loader';

class TeacherMode extends Component {
static propTypes = {
appInstanceId: PropTypes.string,
view: PropTypes.string,
activity: PropTypes.bool,
dispatchGetAppInstanceResources: PropTypes.func.isRequired,
};

static defaultProps = {
view: 'normal',
appInstanceId: null,
activity: false,
};

constructor(props) {
Expand All @@ -34,7 +37,10 @@ class TeacherMode extends Component {
}

render() {
const { view } = this.props;
const { view, activity } = this.props;
if (activity) {
return <Loader />;
}
switch (view) {
case DASHBOARD_VIEW:
return <TeacherDashboard />;
Expand All @@ -44,8 +50,9 @@ class TeacherMode extends Component {
}
}
}
const mapStateToProps = ({ context }) => ({
const mapStateToProps = ({ context, appInstanceResources }) => ({
appInstanceId: context.appInstanceId,
activity: appInstanceResources.activity.length,
});

const mapDispatchToProps = {
Expand Down

0 comments on commit 516e436

Please sign in to comment.