feat: Points for doing reviews

This commit is contained in:
Alexander Polynomdivision
2018-10-01 19:21:57 +02:00
parent d08e591e27
commit 977f5df9dd
7 changed files with 35 additions and 17 deletions

View File

@@ -31,7 +31,8 @@ interface IProps {
setAuthenticated: (status: boolean) => void;
setDidLogin: (status: boolean) => void;
setUser: (user: IUser) => void;
setLastReview: (meta: IReviewMetadata) => void;
setLastReview: (meta: IReviewMetadata, delta: number) => void;
setUserScoreDelta: (delta: number) => void;
};
// TODO: Replace the sessionStorage with localStorage?
@@ -107,9 +108,10 @@ export default class Application extends React.Component<IProps> {
}
// TODO: Type?
setLastReview = (meta: IReviewMetadata, sm2: any) => {
setLastReview = (meta: IReviewMetadata, sm2: any, delta: number) => {
// Update the state
this.props.setLastReview(meta);
this.props.setUserScoreDelta(delta);
// Tell the server about the last review
fetch(`${BACKEND_URL}/api/user/lastReview`, {
@@ -121,6 +123,7 @@ export default class Application extends React.Component<IProps> {
body: JSON.stringify({
meta,
sm2,
delta,
}),
}).then(resp => resp.json(), err => {
console.log("Application::setLastReview: POSTing last results failed");