From e34849ccf22f9ef91a0942d1e2d0a25373b664a0 Mon Sep 17 00:00:00 2001 From: Janani NA Date: Mon, 24 Aug 2020 11:01:39 -0700 Subject: [PATCH 1/7] updated map focus to be where marker is --- client/src/components/Map/Map.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/components/Map/Map.js b/client/src/components/Map/Map.js index 81cc952..344798c 100644 --- a/client/src/components/Map/Map.js +++ b/client/src/components/Map/Map.js @@ -71,6 +71,8 @@ export class MapContainer extends Component { displayMarker = (mapProps, map, clickEvent) => { this.setState({ ...this.state, + latitude: clickEvent.latLng.lat(), + longitude: clickEvent.latLng.lng(), markerLocation: { lat: clickEvent.latLng.lat(), lng: clickEvent.latLng.lng(), From b594eb451adebb13c0f6db410547cab42aa6d756 Mon Sep 17 00:00:00 2001 From: Jack Meier Date: Mon, 24 Aug 2020 11:42:04 -0700 Subject: [PATCH 2/7] added code to get status of quiz guesses --- client/src/pages/Results/ResultCard.js | 3 ++- client/src/pages/Results/Results.js | 27 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/client/src/pages/Results/ResultCard.js b/client/src/pages/Results/ResultCard.js index 27002f6..8fda5d1 100644 --- a/client/src/pages/Results/ResultCard.js +++ b/client/src/pages/Results/ResultCard.js @@ -2,6 +2,7 @@ import React from "react"; import ResultsFacts from "./ResultsFacts"; function ResultCard(props) { + console.log(props); return (
@@ -9,7 +10,7 @@ function ResultCard(props) {
{props.country}
Correct - +
diff --git a/client/src/pages/Results/Results.js b/client/src/pages/Results/Results.js index 3f3a0f9..c6fd4b0 100644 --- a/client/src/pages/Results/Results.js +++ b/client/src/pages/Results/Results.js @@ -7,11 +7,9 @@ import ResultCard from "./ResultCard"; function Results(props) { const continent = useParams().continent; - console.log(continent); const countries = props.location.resultProps.countryList; const guessedCountries = props.location.resultProps.resultList; - console.log(guessedCountries); let correct = 0; let incorrect = 0; @@ -21,12 +19,25 @@ function Results(props) { } else { incorrect++; } - console.log(`Correct: ${correct} Incorrect: ${incorrect}`); } const score = `${(correct / 5) * 100}%`; - console.log(`Your score is: ${score}`); + function getStatus(country) { + let status = "Incorrect"; + for (let i = 1; i < guessedCountries.length; i++) { + let countryStatus = guessedCountries[i]; + console.log("guessedList", guessedCountries); + console.log(country, countryStatus[country]); + if (countryStatus[country] === "Correct") { + status = "Correct"; + return "Correct"; + } + } + if (status === "Incorrect") { + return "Incorrect"; + } + } useEffect(() => { let results = {}; results[continent] = score; @@ -42,7 +53,13 @@ function Results(props) {
{countries.map((country) => { - return ; + return ( + + ); })}
From 7b044b44878898cd7844d20385d6788b8f97c19c Mon Sep 17 00:00:00 2001 From: Jack Meier Date: Mon, 24 Aug 2020 11:54:06 -0700 Subject: [PATCH 3/7] added code to conditionally render correct/incorrect --- client/src/components/Quiz/index.js | 1 - client/src/pages/Home/index.js | 1 - client/src/pages/Results/ResultCard.js | 14 ++++++++------ client/src/pages/Results/Results.js | 2 -- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/client/src/components/Quiz/index.js b/client/src/components/Quiz/index.js index df8a209..3350800 100644 --- a/client/src/components/Quiz/index.js +++ b/client/src/components/Quiz/index.js @@ -34,7 +34,6 @@ function Quiz() { countryArr.current[Math.floor(Math.random() * countryArr.current.length)]; if (questionCount <= 5) { quizArr.push(randomCountry); - console.log(quizArr); } answerList.push(answerFromMap); setCountry(randomCountry); diff --git a/client/src/pages/Home/index.js b/client/src/pages/Home/index.js index eda4057..12a44e8 100644 --- a/client/src/pages/Home/index.js +++ b/client/src/pages/Home/index.js @@ -39,7 +39,6 @@ function Home() { let data = "Continent Not Found"; if (results.length !== 0 && results.length !== "undefined") { for (let i=0;i< results.length;i++){ - console.log("continent",continent) let result = results[i]; if(result.hasOwnProperty(continent)){ data = "Continent Found" diff --git a/client/src/pages/Results/ResultCard.js b/client/src/pages/Results/ResultCard.js index 8fda5d1..a3d64ba 100644 --- a/client/src/pages/Results/ResultCard.js +++ b/client/src/pages/Results/ResultCard.js @@ -1,16 +1,18 @@ import React from "react"; import ResultsFacts from "./ResultsFacts"; -function ResultCard(props) { - console.log(props); - +function ResultCard({ country, status }) { return (
-
{props.country}
- Correct - +
{country}
+ {status === "Correct" ? ( + Correct + ) : ( + Incorrect + )} +
diff --git a/client/src/pages/Results/Results.js b/client/src/pages/Results/Results.js index 5651841..c4902c0 100644 --- a/client/src/pages/Results/Results.js +++ b/client/src/pages/Results/Results.js @@ -25,8 +25,6 @@ function Results(props) { let status = "Incorrect"; for (let i = 1; i < guessedCountries.length; i++) { let countryStatus = guessedCountries[i]; - console.log("guessedList", guessedCountries); - console.log(country, countryStatus[country]); if (countryStatus[country] === "Correct") { status = "Correct"; return "Correct"; From 88b9ab82d39c59230d873f5260f173ac3ae85d57 Mon Sep 17 00:00:00 2001 From: Jack Meier Date: Mon, 24 Aug 2020 12:51:39 -0700 Subject: [PATCH 4/7] added code to save results --- client/src/pages/Results/Results.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/pages/Results/Results.js b/client/src/pages/Results/Results.js index c4902c0..468e4d9 100644 --- a/client/src/pages/Results/Results.js +++ b/client/src/pages/Results/Results.js @@ -1,12 +1,14 @@ import React, { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; +import { useAuth } from "../../utils/auth"; import API from "../../utils/API"; import Button from "react-bootstrap/Button"; import ResultsHeader from "./ResultsHeader"; import ResultCard from "./ResultCard"; + function Results(props) { + const { user, logout } = useAuth(); const continent = useParams().continent; - const countries = props.location.resultProps.countryList; const guessedCountries = props.location.resultProps.resultList; @@ -38,8 +40,8 @@ function Results(props) { let results = {}; results[continent] = score; - API.saveResult("5f4337f4de294f0bfce616a3", results); - }); + API.saveResult(user.id, results); + }, [user.id, score]); return (
From 77c408cdc0649f16a91be73f28e71834ea29c9ca Mon Sep 17 00:00:00 2001 From: Jack Meier Date: Mon, 24 Aug 2020 13:01:40 -0700 Subject: [PATCH 5/7] added .then and .catch to code where results are saved --- client/src/pages/Results/Results.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/pages/Results/Results.js b/client/src/pages/Results/Results.js index 468e4d9..9d1aac5 100644 --- a/client/src/pages/Results/Results.js +++ b/client/src/pages/Results/Results.js @@ -40,7 +40,13 @@ function Results(props) { let results = {}; results[continent] = score; - API.saveResult(user.id, results); + API.saveResult(user.id, results) + .then((res) => { + console.log("Results saved successfully"); + }) + .catch((err) => { + console.log(err); + }); }, [user.id, score]); return (
@@ -72,4 +78,4 @@ function Results(props) {
); } -export default Results; \ No newline at end of file +export default Results; From 1462f9ede027b3bac1620142ce3cce8398d7a387 Mon Sep 17 00:00:00 2001 From: Shelby Anne Date: Mon, 24 Aug 2020 13:36:55 -0700 Subject: [PATCH 6/7] Update index.html --- client/public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/public/index.html b/client/public/index.html index 7bee027..be9295d 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -19,7 +19,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + GeoQuiz