diff --git a/squarenotsquare/src/redux/actions/UserActions.js b/squarenotsquare/src/redux/actions/UserActions.js index d64eadf..66d0c40 100644 --- a/squarenotsquare/src/redux/actions/UserActions.js +++ b/squarenotsquare/src/redux/actions/UserActions.js @@ -1,5 +1,7 @@ import { squareNav } from "../../navigation/SquareNav"; import { SQUARE_FINISHED, SQUARE_START } from "../types/UserTypes"; +import { calculateSquareScore } from "../../libs/CalculateScore"; +import DbAPI from "../../realm/DbAPI"; export function squareStartPressed() { return (dispatch) => { @@ -17,6 +19,9 @@ export function squareFinished(answers, finalTime) { let newUser = {...userState}; newUser.lastGameTime = finalTime; newUser.lastGameAnswers = answers; + + let finalScore = calculateSquareScore(answers, finalTime); + DbAPI.createScore(userState.username, finalScore); dispatch({ type: SQUARE_FINISHED, user: newUser