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