feat: Implement getNextLevel and getTopTenLearners

This commit is contained in:
Alexander Polynomdivision
2018-09-23 16:14:14 +02:00
parent db4b46b5aa
commit 08cd51c2a3
11 changed files with 280 additions and 77 deletions

View File

@@ -8,6 +8,7 @@ import { IReviewMetadata } from "../models/review";
interface IState {
drawer: boolean;
scorePopoverOpen: boolean;
drawerButton: boolean;
authenticated: boolean;
@@ -34,6 +35,11 @@ interface IState {
loading: boolean;
};
dashboard: {
loadingNL: boolean;
loadingTT: boolean;
};
review: {
current: IReviewCard;
@@ -48,6 +54,7 @@ interface IState {
topTen: ILearner[];
nextLevel: ILevel;
lastReview: any;
};
@@ -56,6 +63,8 @@ const initialState: IState = {
drawer: false,
// Should we show the button to open the drawer?
drawerButton: true,
scorePopoverOpen: false,
// Is the user authenticated?
// TODO: Set this to false
authenticated: false,
@@ -83,6 +92,11 @@ const initialState: IState = {
loading: true,
},
dashboard: {
loadingNL: true,
loadingTT: true,
},
review: {
current: {} as IReviewCard,
@@ -95,6 +109,7 @@ const initialState: IState = {
popoverTextColor: "",
},
nextLevel: {} as ILevel,
lastReview: {
correct: 0,
wrong: 0,
@@ -198,6 +213,31 @@ export function LateinicusApp(state: IState = initialState, action: any) {
loading: action.state,
}),
});
case Actions.SET_SCORE_POPOVER:
return Object.assign({}, state, {
scorePopoverOpen: action.state,
});
case Actions.SET_NEXT_LEVEL:
return Object.assign({}, state, {
nextLevel: action.level,
});
case Actions.DASHBOARD_SET_NL_LOADING:
return Object.assign({}, state, {
dashboard: Object.assign({}, state.dashboard, {
loadingNL: action.state,
}),
});
case Actions.SET_TOP_TEN:
console.log(action.topTen);
return Object.assign({}, state, {
topTen: action.topTen,
});
case Actions.DASHBOARD_SET_TT_LOADING:
return Object.assign({}, state, {
dashboard: Object.assign({}, state.dashboard, {
loadingTT: action.state,
}),
});
default:
// Ignore the initialization call to the reducer. By that we can
// catch all actions that are not implemented