fix: Go to the summary page
This commit is contained in:
parent
882ca5a9e3
commit
2dc9aa3a53
@ -110,14 +110,6 @@ export function setReviewPopover(state: boolean, text: string, color: string) {
|
||||
};
|
||||
};
|
||||
|
||||
export const REVIEW_SET_SUMMARY = "REVIEW_SET_SUMMARY";
|
||||
export function setReviewSummary(state: boolean) {
|
||||
return {
|
||||
type: REVIEW_SET_SUMMARY,
|
||||
state,
|
||||
};
|
||||
};
|
||||
|
||||
export const REVIEW_SET_LOADING = "REVIEW_SET_LOADING";
|
||||
export function setReviewLoading(state: boolean) {
|
||||
return {
|
||||
|
@ -11,7 +11,7 @@ import LinearProgress from "@material-ui/core/LinearProgress";
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
|
||||
import { Redirect } from "react-router-dom";
|
||||
import { withRouter } from "react-router-dom";
|
||||
|
||||
import { IVocab, IReviewCard, vocabToReviewCard, reviewQTypeToStr } from "../models/vocab";
|
||||
import { ReviewType, IReviewMetadata } from "../models/review";
|
||||
@ -26,12 +26,13 @@ interface IProps {
|
||||
vocabByLevel?: (level: number) => Promise<IVocab[]>;
|
||||
vocabByQueue?: () => Promise<IVocab[]>;
|
||||
|
||||
history: any;
|
||||
|
||||
reviewType: ReviewType;
|
||||
|
||||
loading: boolean;
|
||||
vocab: IVocab[];
|
||||
current: IReviewCard;
|
||||
toSummary: boolean;
|
||||
popoverOpen: boolean;
|
||||
popoverText: string;
|
||||
popoverColor: string;
|
||||
@ -44,7 +45,8 @@ interface IProps {
|
||||
setLoading: (state: boolean) => void;
|
||||
}
|
||||
|
||||
export default class ReviewPage extends React.Component<IProps> {
|
||||
const ReviewPageWithRouter = withRouter(
|
||||
class ReviewPage extends React.Component<IProps> {
|
||||
private vocab: IVocab[] = [];
|
||||
private reviewQueue: Queue<IReviewCard> = new Queue();
|
||||
// Used for positioning the popover
|
||||
@ -130,7 +132,7 @@ export default class ReviewPage extends React.Component<IProps> {
|
||||
if (this.reviewQueue.size() === 0) {
|
||||
// Go to the summary screen
|
||||
this.props.setLastReview(this.metadata);
|
||||
this.props.setSummary(true);
|
||||
this.props.history.push("/review/summary");
|
||||
} else {
|
||||
// Increase the vocab
|
||||
this.props.setReview(this.reviewQueue.dequeue(), this.increaseMeta(1, 0));
|
||||
@ -159,18 +161,6 @@ export default class ReviewPage extends React.Component<IProps> {
|
||||
render() {
|
||||
if (this.props.loading) {
|
||||
return <div>
|
||||
{/*
|
||||
* This would be the case when the user presses the "to
|
||||
* review" button. That is because we need the state of loading
|
||||
* to be true, when this page gets called
|
||||
* TODO:?
|
||||
*/}
|
||||
{
|
||||
this.props.toSummary ? (
|
||||
<Redirect to="/review/summary" />
|
||||
) : undefined
|
||||
}
|
||||
|
||||
<Grid
|
||||
container
|
||||
spacing={0}
|
||||
@ -197,11 +187,6 @@ export default class ReviewPage extends React.Component<IProps> {
|
||||
const progress = 50;
|
||||
|
||||
return <div>
|
||||
{
|
||||
this.props.toSummary ? (
|
||||
<Redirect to="/review/summary" />
|
||||
) : undefined
|
||||
}
|
||||
<Grid container justify="center">
|
||||
<Grid item style={{ width: "100%" }}>
|
||||
<Card>
|
||||
@ -259,4 +244,6 @@ export default class ReviewPage extends React.Component<IProps> {
|
||||
</Grid>
|
||||
</div>;
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
export default ReviewPageWithRouter;
|
||||
|
@ -37,7 +37,6 @@ interface IState {
|
||||
loading: boolean;
|
||||
vocab: IVocab[];
|
||||
metadata: IReviewMetadata;
|
||||
toSummary: boolean;
|
||||
popoverOpen: boolean;
|
||||
popoverText: string;
|
||||
popoverColor: string;
|
||||
@ -82,7 +81,6 @@ const initialState: IState = {
|
||||
loading: true,
|
||||
vocab: [],
|
||||
metadata: {} as IReviewMetadata,
|
||||
toSummary: false,
|
||||
popoverOpen: false,
|
||||
popoverText: "",
|
||||
popoverColor: "",
|
||||
@ -193,12 +191,6 @@ export function LateinicusApp(state: IState = initialState, action: any) {
|
||||
loading: action.state,
|
||||
}),
|
||||
});
|
||||
case Actions.REVIEW_SET_SUMMARY:
|
||||
return Object.assign({}, state, {
|
||||
review: Object.assign({}, state.review, {
|
||||
toSummary: action.state,
|
||||
}),
|
||||
});
|
||||
default:
|
||||
if (action.type) {
|
||||
console.log("Reducer not implemented:", action.type);
|
||||
|
Reference in New Issue
Block a user