diff --git a/questionservice/question-service.js b/questionservice/question-service.js index 512809c..d93d585 100644 --- a/questionservice/question-service.js +++ b/questionservice/question-service.js @@ -212,26 +212,33 @@ app.get('/imgs/foods/question', async (req, res) => { app.post('/imgs/answer', async (req, res) => { try { const obj = req.body; - - if (obj.question == answerToQuestionMap.get(obj.answer)) { - await axios.post(userServiceUrl + '/addpoints', - { username: obj.username, category: obj.category, correct: "true" }); - res.status(200).json({ - correct: "true", - }) + if (obj.answer !== "TimeOut1234;") { + if (obj.question == answerToQuestionMap.get(obj.answer)) { + await axios.post(userServiceUrl + '/addpoints', + { username: obj.username, category: obj.category, correct: "true" }); + res.status(200).json({ + correct: "true", + }) + } else { + await axios.post(userServiceUrl + '/addpoints', + { username: obj.username, category: obj.category, correct: "false" }); + res.status(200).json({ + correct: "false", + correctImg: `${[...answerToQuestionMap].find(([key, val]) => val == obj.question)[0]}` + }) + } } else { - await axios.post(userServiceUrl + '/addpoints', - { username: obj.username, category: obj.category, correct: "false" }); res.status(200).json({ correct: "false", - associate: `${imgToAssociatedMap.get(obj.answer)}` + correctImg: `${[...answerToQuestionMap].find(([key, val]) => val == obj.question)[0]}` }) } - } catch (e) { //SIEMPRE RODEAR CON TRY CATCH - res.status(500).json({ error: e.message }) - } -}); + } catch (e) { //SIEMPRE RODEAR CON TRY CATCH + console.error(e) + res.status(500).json({ error: e.message }) + } + }); const server = app.listen(port, () => { console.log(`Questions service listening on http://localhost:${port}`); diff --git a/webapp/.eslintignore b/webapp/.eslintignore new file mode 100644 index 0000000..51d191e --- /dev/null +++ b/webapp/.eslintignore @@ -0,0 +1,3 @@ +build/ +src/ +*.js \ No newline at end of file diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 3a036d1..337894f 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -5,11 +5,13 @@ "requires": true, "packages": { "": { + "name": "webapp", "version": "0.1.0", "dependencies": { - "@emotion/react": "^11.11.3", - "@emotion/styled": "^11.11.0", - "@mui/material": "^5.15.3", + "@emotion/react": "^11.11.4", + "@emotion/styled": "^11.11.5", + "@mui/icons-material": "^5.15.15", + "@mui/material": "^5.15.15", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^14.1.2", "@testing-library/user-event": "^14.5.2", @@ -1972,9 +1974,9 @@ "integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==" }, "node_modules/@babel/runtime": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.7.tgz", - "integrity": "sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz", + "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -2379,9 +2381,9 @@ "integrity": "sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==" }, "node_modules/@emotion/is-prop-valid": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz", - "integrity": "sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", + "integrity": "sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==", "dependencies": { "@emotion/memoize": "^0.8.1" } @@ -2392,9 +2394,9 @@ "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" }, "node_modules/@emotion/react": { - "version": "11.11.3", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.3.tgz", - "integrity": "sha512-Cnn0kuq4DoONOMcnoVsTOR8E+AdnKFf//6kUWc4LCdnxj31pZWn7rIULd6Y7/Js1PiPHzn7SKCM9vB/jBni8eA==", + "version": "11.11.4", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.4.tgz", + "integrity": "sha512-t8AjMlF0gHpvvxk5mAtCqR4vmxiGHCeJBaQO6gncUSdklELOgtwjerNY2yuJNfwnc6vi16U/+uMF+afIawJ9iw==", "dependencies": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.11.0", @@ -2415,9 +2417,9 @@ } }, "node_modules/@emotion/serialize": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.3.tgz", - "integrity": "sha512-iD4D6QVZFDhcbH0RAG1uVu1CwVLMWUkCvAqqlewO/rxf8+87yIBAlt4+AxMiiKPLs5hFc0owNk/sLLAOROw3cA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.4.tgz", + "integrity": "sha512-RIN04MBT8g+FnDwgvIUi8czvr1LU1alUMI05LekWB5DGyTm8cCBMCRpq3GqaiyEDRptEXOyXnvZ58GZYu4kBxQ==", "dependencies": { "@emotion/hash": "^0.9.1", "@emotion/memoize": "^0.8.1", @@ -2432,14 +2434,14 @@ "integrity": "sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==" }, "node_modules/@emotion/styled": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.11.0.tgz", - "integrity": "sha512-hM5Nnvu9P3midq5aaXj4I+lnSfNi7Pmd4EWk1fOZ3pxookaQTNew6bp4JaCBYM4HVFZF9g7UjJmsUmC2JlxOng==", + "version": "11.11.5", + "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.11.5.tgz", + "integrity": "sha512-/ZjjnaNKvuMPxcIiUkf/9SHoG4Q196DRl1w82hQ3WCsjo1IUR8uaGWrC6a87CrYAW0Kb/pK7hk8BnLgLRi9KoQ==", "dependencies": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.11.0", - "@emotion/is-prop-valid": "^1.2.1", - "@emotion/serialize": "^1.1.2", + "@emotion/is-prop-valid": "^1.2.2", + "@emotion/serialize": "^1.1.4", "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", "@emotion/utils": "^1.2.1" }, @@ -2570,28 +2572,28 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.5.3.tgz", - "integrity": "sha512-O0WKDOo0yhJuugCx6trZQj5jVJ9yR0ystG2JaNAemYUWce+pmM6WUEFIibnWyEJKdrDxhm75NoSRME35FNaM/Q==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.0.tgz", + "integrity": "sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==", "dependencies": { - "@floating-ui/utils": "^0.2.0" + "@floating-ui/utils": "^0.2.1" } }, "node_modules/@floating-ui/dom": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.5.4.tgz", - "integrity": "sha512-jByEsHIY+eEdCjnTVu+E3ephzTOzkQ8hgUfGwos+bg7NlH33Zc5uO+QHz1mrQUOgIKKDD1RtS201P9NvAfq3XQ==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.3.tgz", + "integrity": "sha512-RnDthu3mzPlQ31Ss/BTwQ1zjzIhr3lk1gZB1OC56h/1vEtaXkESrOqL5fQVMfXpwGtRwX+YsZBdyHtJMQnkArw==", "dependencies": { - "@floating-ui/core": "^1.5.3", + "@floating-ui/core": "^1.0.0", "@floating-ui/utils": "^0.2.0" } }, "node_modules/@floating-ui/react-dom": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.5.tgz", - "integrity": "sha512-UsBK30Bg+s6+nsgblXtZmwHhgS2vmbuQK22qgt2pTQM6M3X6H1+cQcLXqgRY3ihVLcZJE6IvqDQozhsnIVqK/Q==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.8.tgz", + "integrity": "sha512-HOdqOt3R3OGeTKidaLvJKcgg75S6tibQ3Tif4eyd91QnIJWr0NLvoXFpJA/j8HqkFSL68GDca9AuyWEHlhyClw==", "dependencies": { - "@floating-ui/dom": "^1.5.4" + "@floating-ui/dom": "^1.6.1" }, "peerDependencies": { "react": ">=16.8.0", @@ -4527,16 +4529,16 @@ } }, "node_modules/@mui/base": { - "version": "5.0.0-beta.30", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.30.tgz", - "integrity": "sha512-dc38W4W3K42atE9nSaOeoJ7/x9wGIfawdwC/UmMxMLlZ1iSsITQ8dQJaTATCbn98YvYPINK/EH541YA5enQIPQ==", - "dependencies": { - "@babel/runtime": "^7.23.6", - "@floating-ui/react-dom": "^2.0.4", - "@mui/types": "^7.2.12", - "@mui/utils": "^5.15.3", + "version": "5.0.0-beta.40", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.40.tgz", + "integrity": "sha512-I/lGHztkCzvwlXpjD2+SNmvNQvB4227xBXhISPjEaJUXGImOQ9f3D2Yj/T3KasSI/h0MLWy74X0J6clhPmsRbQ==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@floating-ui/react-dom": "^2.0.8", + "@mui/types": "^7.2.14", + "@mui/utils": "^5.15.14", "@popperjs/core": "^2.11.8", - "clsx": "^2.0.0", + "clsx": "^2.1.0", "prop-types": "^15.8.1" }, "engines": { @@ -4558,28 +4560,53 @@ } }, "node_modules/@mui/core-downloads-tracker": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.15.3.tgz", - "integrity": "sha512-sWeihiVyxdJjpLkp8SHkTy9kt2M/o11M60G1MzwljGL2BXdM3Ktzqv5QaQHdi00y7Y1ulvtI3GOSxP2xU8mQJw==", + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.15.15.tgz", + "integrity": "sha512-aXnw29OWQ6I5A47iuWEI6qSSUfH6G/aCsW9KmW3LiFqr7uXZBK4Ks+z8G+qeIub8k0T5CMqlT2q0L+ZJTMrqpg==", "funding": { "type": "opencollective", "url": "https://opencollective.com/mui-org" } }, + "node_modules/@mui/icons-material": { + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.15.15.tgz", + "integrity": "sha512-kkeU/pe+hABcYDH6Uqy8RmIsr2S/y5bP2rp+Gat4CcRjCcVne6KudS1NrZQhUCRysrTDCAhcbcf9gt+/+pGO2g==", + "dependencies": { + "@babel/runtime": "^7.23.9" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mui-org" + }, + "peerDependencies": { + "@mui/material": "^5.0.0", + "@types/react": "^17.0.0 || ^18.0.0", + "react": "^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/@mui/material": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.3.tgz", - "integrity": "sha512-DODBBMouyq1B5f3YkEWL9vO8pGCxuEGqtfpltF6peMJzz/78tJFyLQsDas9MNLC/8AdFu2BQdkK7wox5UBPTAA==", - "dependencies": { - "@babel/runtime": "^7.23.6", - "@mui/base": "5.0.0-beta.30", - "@mui/core-downloads-tracker": "^5.15.3", - "@mui/system": "^5.15.3", - "@mui/types": "^7.2.12", - "@mui/utils": "^5.15.3", + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.15.tgz", + "integrity": "sha512-3zvWayJ+E1kzoIsvwyEvkTUKVKt1AjchFFns+JtluHCuvxgKcLSRJTADw37k0doaRtVAsyh8bz9Afqzv+KYrIA==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@mui/base": "5.0.0-beta.40", + "@mui/core-downloads-tracker": "^5.15.15", + "@mui/system": "^5.15.15", + "@mui/types": "^7.2.14", + "@mui/utils": "^5.15.14", "@types/react-transition-group": "^4.4.10", - "clsx": "^2.0.0", - "csstype": "^3.1.2", + "clsx": "^2.1.0", + "csstype": "^3.1.3", "prop-types": "^15.8.1", "react-is": "^18.2.0", "react-transition-group": "^4.4.5" @@ -4616,12 +4643,12 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" }, "node_modules/@mui/private-theming": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.15.3.tgz", - "integrity": "sha512-Q79MhVMmywC1l5bMsMZq5PsIudr1MNPJnx9/EqdMP0vpz5iNvFpnLmxsD7d8/hqTWgFAljI+LH3jX8MxlZH9Gw==", + "version": "5.15.14", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.15.14.tgz", + "integrity": "sha512-UH0EiZckOWcxiXLX3Jbb0K7rC8mxTr9L9l6QhOZxYc4r8FHUkefltV9VDGLrzCaWh30SQiJvAEd7djX3XXY6Xw==", "dependencies": { - "@babel/runtime": "^7.23.6", - "@mui/utils": "^5.15.3", + "@babel/runtime": "^7.23.9", + "@mui/utils": "^5.15.14", "prop-types": "^15.8.1" }, "engines": { @@ -4642,13 +4669,13 @@ } }, "node_modules/@mui/styled-engine": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.15.3.tgz", - "integrity": "sha512-+d5XZCTeemOO/vBfWGEeHgTm8fjU1Psdgm+xAw+uegycO2EnoA/EfGSaG5UwZ6g3b66y48Mkxi35AggShMr88w==", + "version": "5.15.14", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.15.14.tgz", + "integrity": "sha512-RILkuVD8gY6PvjZjqnWhz8fu68dVkqhM5+jYWfB5yhlSQKg+2rHkmEwm75XIeAqI3qwOndK6zELK5H6Zxn4NHw==", "dependencies": { - "@babel/runtime": "^7.23.6", + "@babel/runtime": "^7.23.9", "@emotion/cache": "^11.11.0", - "csstype": "^3.1.2", + "csstype": "^3.1.3", "prop-types": "^15.8.1" }, "engines": { @@ -4673,17 +4700,17 @@ } }, "node_modules/@mui/system": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.15.3.tgz", - "integrity": "sha512-ewVU4eRgo4VfNMGpO61cKlfWmH7l9s6rA8EknRzuMX3DbSLfmtW2WJJg6qPwragvpPIir0Pp/AdWVSDhyNy5Tw==", - "dependencies": { - "@babel/runtime": "^7.23.6", - "@mui/private-theming": "^5.15.3", - "@mui/styled-engine": "^5.15.3", - "@mui/types": "^7.2.12", - "@mui/utils": "^5.15.3", - "clsx": "^2.0.0", - "csstype": "^3.1.2", + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.15.15.tgz", + "integrity": "sha512-aulox6N1dnu5PABsfxVGOZffDVmlxPOVgj56HrUnJE8MCSh8lOvvkd47cebIVQQYAjpwieXQXiDPj5pwM40jTQ==", + "dependencies": { + "@babel/runtime": "^7.23.9", + "@mui/private-theming": "^5.15.14", + "@mui/styled-engine": "^5.15.14", + "@mui/types": "^7.2.14", + "@mui/utils": "^5.15.14", + "clsx": "^2.1.0", + "csstype": "^3.1.3", "prop-types": "^15.8.1" }, "engines": { @@ -4712,9 +4739,9 @@ } }, "node_modules/@mui/types": { - "version": "7.2.12", - "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.12.tgz", - "integrity": "sha512-3kaHiNm9khCAo0pVe0RenketDSFoZGAlVZ4zDjB/QNZV0XiCj+sh1zkX0VVhQPgYJDlBEzAag+MHJ1tU3vf0Zw==", + "version": "7.2.14", + "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.14.tgz", + "integrity": "sha512-MZsBZ4q4HfzBsywtXgM1Ksj6HDThtiwmOKUXH1pKYISI9gAVXCNHNpo7TlGoGrBaYWZTdNoirIN7JsQcQUjmQQ==", "peerDependencies": { "@types/react": "^17.0.0 || ^18.0.0" }, @@ -4725,11 +4752,11 @@ } }, "node_modules/@mui/utils": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.15.3.tgz", - "integrity": "sha512-mT3LiSt9tZWCdx1pl7q4Q5tNo6gdZbvJel286ZHGuj6LQQXjWNAh8qiF9d+LogvNUI+D7eLkTnj605d1zoazfg==", + "version": "5.15.14", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.15.14.tgz", + "integrity": "sha512-0lF/7Hh/ezDv5X7Pry6enMsbYyGKjADzvHyo3Qrc/SSlTsQ1VkbDMbH0m2t3OR5iIVLwMoxwM7yGd+6FCMtTFA==", "dependencies": { - "@babel/runtime": "^7.23.6", + "@babel/runtime": "^7.23.9", "@types/prop-types": "^15.7.11", "prop-types": "^15.8.1", "react-is": "^18.2.0" @@ -29372,9 +29399,9 @@ "integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==" }, "@babel/runtime": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.7.tgz", - "integrity": "sha512-w06OXVOFso7LcbzMiDGt+3X7Rh7Ho8MmgPoWU3rarH+8upf+wSU/grlGbWzQyr3DkdN6ZeuMFjpdwW0Q+HxobA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz", + "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==", "requires": { "regenerator-runtime": "^0.14.0" } @@ -29610,9 +29637,9 @@ "integrity": "sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==" }, "@emotion/is-prop-valid": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz", - "integrity": "sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", + "integrity": "sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==", "requires": { "@emotion/memoize": "^0.8.1" } @@ -29623,9 +29650,9 @@ "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" }, "@emotion/react": { - "version": "11.11.3", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.3.tgz", - "integrity": "sha512-Cnn0kuq4DoONOMcnoVsTOR8E+AdnKFf//6kUWc4LCdnxj31pZWn7rIULd6Y7/Js1PiPHzn7SKCM9vB/jBni8eA==", + "version": "11.11.4", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.4.tgz", + "integrity": "sha512-t8AjMlF0gHpvvxk5mAtCqR4vmxiGHCeJBaQO6gncUSdklELOgtwjerNY2yuJNfwnc6vi16U/+uMF+afIawJ9iw==", "requires": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.11.0", @@ -29638,9 +29665,9 @@ } }, "@emotion/serialize": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.3.tgz", - "integrity": "sha512-iD4D6QVZFDhcbH0RAG1uVu1CwVLMWUkCvAqqlewO/rxf8+87yIBAlt4+AxMiiKPLs5hFc0owNk/sLLAOROw3cA==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.4.tgz", + "integrity": "sha512-RIN04MBT8g+FnDwgvIUi8czvr1LU1alUMI05LekWB5DGyTm8cCBMCRpq3GqaiyEDRptEXOyXnvZ58GZYu4kBxQ==", "requires": { "@emotion/hash": "^0.9.1", "@emotion/memoize": "^0.8.1", @@ -29655,14 +29682,14 @@ "integrity": "sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==" }, "@emotion/styled": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.11.0.tgz", - "integrity": "sha512-hM5Nnvu9P3midq5aaXj4I+lnSfNi7Pmd4EWk1fOZ3pxookaQTNew6bp4JaCBYM4HVFZF9g7UjJmsUmC2JlxOng==", + "version": "11.11.5", + "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.11.5.tgz", + "integrity": "sha512-/ZjjnaNKvuMPxcIiUkf/9SHoG4Q196DRl1w82hQ3WCsjo1IUR8uaGWrC6a87CrYAW0Kb/pK7hk8BnLgLRi9KoQ==", "requires": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.11.0", - "@emotion/is-prop-valid": "^1.2.1", - "@emotion/serialize": "^1.1.2", + "@emotion/is-prop-valid": "^1.2.2", + "@emotion/serialize": "^1.1.4", "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", "@emotion/utils": "^1.2.1" } @@ -29751,28 +29778,28 @@ "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==" }, "@floating-ui/core": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.5.3.tgz", - "integrity": "sha512-O0WKDOo0yhJuugCx6trZQj5jVJ9yR0ystG2JaNAemYUWce+pmM6WUEFIibnWyEJKdrDxhm75NoSRME35FNaM/Q==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.0.tgz", + "integrity": "sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==", "requires": { - "@floating-ui/utils": "^0.2.0" + "@floating-ui/utils": "^0.2.1" } }, "@floating-ui/dom": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.5.4.tgz", - "integrity": "sha512-jByEsHIY+eEdCjnTVu+E3ephzTOzkQ8hgUfGwos+bg7NlH33Zc5uO+QHz1mrQUOgIKKDD1RtS201P9NvAfq3XQ==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.3.tgz", + "integrity": "sha512-RnDthu3mzPlQ31Ss/BTwQ1zjzIhr3lk1gZB1OC56h/1vEtaXkESrOqL5fQVMfXpwGtRwX+YsZBdyHtJMQnkArw==", "requires": { - "@floating-ui/core": "^1.5.3", + "@floating-ui/core": "^1.0.0", "@floating-ui/utils": "^0.2.0" } }, "@floating-ui/react-dom": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.5.tgz", - "integrity": "sha512-UsBK30Bg+s6+nsgblXtZmwHhgS2vmbuQK22qgt2pTQM6M3X6H1+cQcLXqgRY3ihVLcZJE6IvqDQozhsnIVqK/Q==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.8.tgz", + "integrity": "sha512-HOdqOt3R3OGeTKidaLvJKcgg75S6tibQ3Tif4eyd91QnIJWr0NLvoXFpJA/j8HqkFSL68GDca9AuyWEHlhyClw==", "requires": { - "@floating-ui/dom": "^1.5.4" + "@floating-ui/dom": "^1.6.1" } }, "@floating-ui/utils": { @@ -31262,38 +31289,46 @@ } }, "@mui/base": { - "version": "5.0.0-beta.30", - "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.30.tgz", - "integrity": "sha512-dc38W4W3K42atE9nSaOeoJ7/x9wGIfawdwC/UmMxMLlZ1iSsITQ8dQJaTATCbn98YvYPINK/EH541YA5enQIPQ==", - "requires": { - "@babel/runtime": "^7.23.6", - "@floating-ui/react-dom": "^2.0.4", - "@mui/types": "^7.2.12", - "@mui/utils": "^5.15.3", + "version": "5.0.0-beta.40", + "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.40.tgz", + "integrity": "sha512-I/lGHztkCzvwlXpjD2+SNmvNQvB4227xBXhISPjEaJUXGImOQ9f3D2Yj/T3KasSI/h0MLWy74X0J6clhPmsRbQ==", + "requires": { + "@babel/runtime": "^7.23.9", + "@floating-ui/react-dom": "^2.0.8", + "@mui/types": "^7.2.14", + "@mui/utils": "^5.15.14", "@popperjs/core": "^2.11.8", - "clsx": "^2.0.0", + "clsx": "^2.1.0", "prop-types": "^15.8.1" } }, "@mui/core-downloads-tracker": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.15.3.tgz", - "integrity": "sha512-sWeihiVyxdJjpLkp8SHkTy9kt2M/o11M60G1MzwljGL2BXdM3Ktzqv5QaQHdi00y7Y1ulvtI3GOSxP2xU8mQJw==" + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.15.15.tgz", + "integrity": "sha512-aXnw29OWQ6I5A47iuWEI6qSSUfH6G/aCsW9KmW3LiFqr7uXZBK4Ks+z8G+qeIub8k0T5CMqlT2q0L+ZJTMrqpg==" + }, + "@mui/icons-material": { + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/icons-material/-/icons-material-5.15.15.tgz", + "integrity": "sha512-kkeU/pe+hABcYDH6Uqy8RmIsr2S/y5bP2rp+Gat4CcRjCcVne6KudS1NrZQhUCRysrTDCAhcbcf9gt+/+pGO2g==", + "requires": { + "@babel/runtime": "^7.23.9" + } }, "@mui/material": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.3.tgz", - "integrity": "sha512-DODBBMouyq1B5f3YkEWL9vO8pGCxuEGqtfpltF6peMJzz/78tJFyLQsDas9MNLC/8AdFu2BQdkK7wox5UBPTAA==", - "requires": { - "@babel/runtime": "^7.23.6", - "@mui/base": "5.0.0-beta.30", - "@mui/core-downloads-tracker": "^5.15.3", - "@mui/system": "^5.15.3", - "@mui/types": "^7.2.12", - "@mui/utils": "^5.15.3", + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/material/-/material-5.15.15.tgz", + "integrity": "sha512-3zvWayJ+E1kzoIsvwyEvkTUKVKt1AjchFFns+JtluHCuvxgKcLSRJTADw37k0doaRtVAsyh8bz9Afqzv+KYrIA==", + "requires": { + "@babel/runtime": "^7.23.9", + "@mui/base": "5.0.0-beta.40", + "@mui/core-downloads-tracker": "^5.15.15", + "@mui/system": "^5.15.15", + "@mui/types": "^7.2.14", + "@mui/utils": "^5.15.14", "@types/react-transition-group": "^4.4.10", - "clsx": "^2.0.0", - "csstype": "^3.1.2", + "clsx": "^2.1.0", + "csstype": "^3.1.3", "prop-types": "^15.8.1", "react-is": "^18.2.0", "react-transition-group": "^4.4.5" @@ -31307,53 +31342,53 @@ } }, "@mui/private-theming": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.15.3.tgz", - "integrity": "sha512-Q79MhVMmywC1l5bMsMZq5PsIudr1MNPJnx9/EqdMP0vpz5iNvFpnLmxsD7d8/hqTWgFAljI+LH3jX8MxlZH9Gw==", + "version": "5.15.14", + "resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.15.14.tgz", + "integrity": "sha512-UH0EiZckOWcxiXLX3Jbb0K7rC8mxTr9L9l6QhOZxYc4r8FHUkefltV9VDGLrzCaWh30SQiJvAEd7djX3XXY6Xw==", "requires": { - "@babel/runtime": "^7.23.6", - "@mui/utils": "^5.15.3", + "@babel/runtime": "^7.23.9", + "@mui/utils": "^5.15.14", "prop-types": "^15.8.1" } }, "@mui/styled-engine": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.15.3.tgz", - "integrity": "sha512-+d5XZCTeemOO/vBfWGEeHgTm8fjU1Psdgm+xAw+uegycO2EnoA/EfGSaG5UwZ6g3b66y48Mkxi35AggShMr88w==", + "version": "5.15.14", + "resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.15.14.tgz", + "integrity": "sha512-RILkuVD8gY6PvjZjqnWhz8fu68dVkqhM5+jYWfB5yhlSQKg+2rHkmEwm75XIeAqI3qwOndK6zELK5H6Zxn4NHw==", "requires": { - "@babel/runtime": "^7.23.6", + "@babel/runtime": "^7.23.9", "@emotion/cache": "^11.11.0", - "csstype": "^3.1.2", + "csstype": "^3.1.3", "prop-types": "^15.8.1" } }, "@mui/system": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.15.3.tgz", - "integrity": "sha512-ewVU4eRgo4VfNMGpO61cKlfWmH7l9s6rA8EknRzuMX3DbSLfmtW2WJJg6qPwragvpPIir0Pp/AdWVSDhyNy5Tw==", - "requires": { - "@babel/runtime": "^7.23.6", - "@mui/private-theming": "^5.15.3", - "@mui/styled-engine": "^5.15.3", - "@mui/types": "^7.2.12", - "@mui/utils": "^5.15.3", - "clsx": "^2.0.0", - "csstype": "^3.1.2", + "version": "5.15.15", + "resolved": "https://registry.npmjs.org/@mui/system/-/system-5.15.15.tgz", + "integrity": "sha512-aulox6N1dnu5PABsfxVGOZffDVmlxPOVgj56HrUnJE8MCSh8lOvvkd47cebIVQQYAjpwieXQXiDPj5pwM40jTQ==", + "requires": { + "@babel/runtime": "^7.23.9", + "@mui/private-theming": "^5.15.14", + "@mui/styled-engine": "^5.15.14", + "@mui/types": "^7.2.14", + "@mui/utils": "^5.15.14", + "clsx": "^2.1.0", + "csstype": "^3.1.3", "prop-types": "^15.8.1" } }, "@mui/types": { - "version": "7.2.12", - "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.12.tgz", - "integrity": "sha512-3kaHiNm9khCAo0pVe0RenketDSFoZGAlVZ4zDjB/QNZV0XiCj+sh1zkX0VVhQPgYJDlBEzAag+MHJ1tU3vf0Zw==", + "version": "7.2.14", + "resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.14.tgz", + "integrity": "sha512-MZsBZ4q4HfzBsywtXgM1Ksj6HDThtiwmOKUXH1pKYISI9gAVXCNHNpo7TlGoGrBaYWZTdNoirIN7JsQcQUjmQQ==", "requires": {} }, "@mui/utils": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.15.3.tgz", - "integrity": "sha512-mT3LiSt9tZWCdx1pl7q4Q5tNo6gdZbvJel286ZHGuj6LQQXjWNAh8qiF9d+LogvNUI+D7eLkTnj605d1zoazfg==", + "version": "5.15.14", + "resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.15.14.tgz", + "integrity": "sha512-0lF/7Hh/ezDv5X7Pry6enMsbYyGKjADzvHyo3Qrc/SSlTsQ1VkbDMbH0m2t3OR5iIVLwMoxwM7yGd+6FCMtTFA==", "requires": { - "@babel/runtime": "^7.23.6", + "@babel/runtime": "^7.23.9", "@types/prop-types": "^15.7.11", "prop-types": "^15.8.1", "react-is": "^18.2.0" diff --git a/webapp/package.json b/webapp/package.json index a4f0d2d..be7abce 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -3,9 +3,10 @@ "version": "0.1.0", "private": true, "dependencies": { - "@emotion/react": "^11.11.3", - "@emotion/styled": "^11.11.0", - "@mui/material": "^5.15.3", + "@emotion/react": "^11.11.4", + "@emotion/styled": "^11.11.5", + "@mui/icons-material": "^5.15.15", + "@mui/material": "^5.15.15", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^14.1.2", "@testing-library/user-event": "^14.5.2", diff --git a/webapp/public/WIQProvFondo.png b/webapp/public/WIQProvFondo.png new file mode 100644 index 0000000..ead6e86 Binary files /dev/null and b/webapp/public/WIQProvFondo.png differ diff --git a/webapp/public/WIQProvSin.png b/webapp/public/WIQProvSin.png new file mode 100644 index 0000000..0aed625 Binary files /dev/null and b/webapp/public/WIQProvSin.png differ diff --git a/webapp/public/favicon.ico b/webapp/public/favicon.ico index a11777c..ead6e86 100644 Binary files a/webapp/public/favicon.ico and b/webapp/public/favicon.ico differ diff --git a/webapp/src/App.jsx b/webapp/src/App.jsx index 80e81ba..fdc7ba8 100644 --- a/webapp/src/App.jsx +++ b/webapp/src/App.jsx @@ -6,6 +6,7 @@ import Login from './components/Login'; import RankingsLayout from './components/ranking/RankingLayout'; import Game from './components/Game'; import MainPage from './components/MainPage'; +import Squads from './components/Squads'; function App() { // const isAuthenticated = useIsAuthenticated() // True if user has logged in @@ -23,6 +24,7 @@ function App() { } /> } /> } /> + } /> ) diff --git a/webapp/src/components/AddUser.jsx b/webapp/src/components/AddUser.jsx index a464500..e8b2a28 100644 --- a/webapp/src/components/AddUser.jsx +++ b/webapp/src/components/AddUser.jsx @@ -1,7 +1,7 @@ // src/components/AddUser.js import React, { useState } from 'react'; import axios from 'axios'; -import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; +import { Snackbar } from '@mui/material'; import { Link } from 'react-router-dom'; import { useNavigate } from 'react-router-dom'; const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; @@ -17,18 +17,19 @@ const AddUser = () => { const addUser = async () => { try { - if(password!==cpassword){ + if (password !== cpassword) { setError("Passwords do not match"); return; } await axios.post(`${apiEndpoint}/adduser`, { username, email, password }); setOpenSnackbar(true); navigate('/login'); + } catch (error) { - if(error.response===undefined){ + if (error.response === undefined) { setError("There was a problem..."); } - else{ + else { setError(error.response.data.error); } } @@ -39,57 +40,58 @@ const AddUser = () => { }; return ( - - - Register - - setUsername(e.target.value)} - /> - setEmail(e.target.value)} - /> - setPassword(e.target.value)} - /> - setcPassword(e.target.value)} - /> - - - Already have an account? Log in here. - + +
+
+
+
+ Logo +
+

WIQ

+ +
+
Sign up for an account on WIQ.
+
+
+ +
+ setUsername(e.target.value)} class="pl-12 mb-2 bg-gray-50 text-gray-600 border focus:border-transparent border-gray-300 sm:text-sm rounded-lg ring ring-transparent focus:ring-1 focus:outline-none focus:ring-gray-400 block w-full p-2.5 rounded-l-lg py-3 px-4" placeholder="Username" /> +
+
+
+ +
+ setEmail(e.target.value)} class="pl-12 mb-2 bg-gray-50 text-gray-600 border focus:border-transparent border-gray-300 sm:text-sm rounded-lg ring ring-transparent focus:ring-1 focus:outline-none focus:ring-gray-400 block w-full p-2.5 rounded-l-lg py-3 px-4" placeholder="name@example.com" /> +
+
+
+ +
+ setPassword(e.target.value)} placeholder="••••••••••" class="pl-12 mb-2 bg-gray-50 text-gray-600 border focus:border-transparent border-gray-300 sm:text-sm rounded-lg ring ring-transparent focus:ring-1 focus:outline-none focus:ring-gray-400 block w-full p-2.5 rounded-l-lg py-3 px-4" autocomplete="new-password" /> +
+
+
+ +
+ setcPassword(e.target.value)} placeholder="••••••••••" class="pl-12 mb-2 bg-gray-50 text-gray-600 border focus:border-transparent border-gray-300 sm:text-sm rounded-lg ring ring-transparent focus:ring-1 focus:outline-none focus:ring-gray-400 block w-full p-2.5 rounded-l-lg py-3 px-4" autocomplete="new-password" /> +
+
+ +
Already have an account? Login + +
+
+
+ - {error && ( - setError('')} message={`Error: ${error}`} /> - )} - + { + error && ( + setError('')} message={`Error: ${error}`} /> + ) + } +
+ //
+ ); }; diff --git a/webapp/src/components/ImgGameReport.jsx b/webapp/src/components/ImgGameReport.jsx new file mode 100644 index 0000000..b18c968 --- /dev/null +++ b/webapp/src/components/ImgGameReport.jsx @@ -0,0 +1,67 @@ +import React, { useEffect } from "react"; +import CheckIcon from '@mui/icons-material/Check'; +import ClearIcon from '@mui/icons-material/Clear'; +import { useNavigate } from "react-router-dom"; +const ImgGameReport = (props) => { + const answers = props.answers; + const navigate = useNavigate(); + const loadRankings = () => { + navigate("/rankings"); + } + return ( +
+
+
+
+

Game Over!

+

+ You answered {props.score} {props.score === 1 ? "question" : "questions"} correctly +

+ + +
+
+
+
+ + + {answers.map((answer) => { + return ( +
+
+ Card Preview +
+
+
{answer.question}
+
+ You answered the question {answer.correct === "true" ? "correctly" : "wrongly"} + {answer.correct === "true" ? : } +
+
+
+ ); + })} +
+
+ ); +} + +export default ImgGameReport; \ No newline at end of file diff --git a/webapp/src/components/Login.jsx b/webapp/src/components/Login.jsx index d1d7132..da04949 100644 --- a/webapp/src/components/Login.jsx +++ b/webapp/src/components/Login.jsx @@ -1,24 +1,24 @@ // src/components/Login.js import React, { useState } from 'react'; import axios from 'axios'; -import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; +import { Snackbar } from '@mui/material'; import useSignIn from 'react-auth-kit/hooks/useSignIn'; -import { useNavigate } from 'react-router-dom'; +// import { useNavigate } from 'react-router-dom'; import { Link } from 'react-router-dom'; const Login = () => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const signIn = useSignIn(); - const navigate = useNavigate(); + // const navigate = useNavigate(); const [openSnackbar, setOpenSnackbar] = useState(false); const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; const loginUser = async () => { try { - const response = await axios.post(`${apiEndpoint}/login`, { username, password }).then((res) => { - + await axios.post(`${apiEndpoint}/login`, { username, password }).then((res) => { + if (res.status === 200) { if (signIn({ auth: { @@ -33,22 +33,23 @@ const Login = () => { } })) { // Only if you are using refreshToken feature // Redirect or do-something - navigate('/'); + // navigate('/'); + window.location.href = '/'; } else { //Throw error throw new Error('Error while signing in'); } - } + } }); setOpenSnackbar(true); } catch (error) { - if(error.response===undefined){ + if (error.response === undefined) { setError("Error: There was a problem..."); } - else{ + else { setError(error.response.data.error); } @@ -60,46 +61,46 @@ const Login = () => { }; return ( - -
- - Login - - setUsername(e.target.value)} - /> - setPassword(e.target.value)} - /> - - - - - Don't have an account? Register here. - - - - - - {error && ( - setError('')} message={`Error: ${error}`} /> - )} -
+ +
+
+
+
+ Logo +
+

WIQ

+ +
+
Acces to WIQ with your account.
+
+
+ +
+ setUsername(e.target.value)} class="pl-12 mb-2 bg-gray-50 text-gray-600 border focus:border-transparent border-gray-300 sm:text-sm rounded-lg ring ring-transparent focus:ring-1 focus:outline-none focus:ring-gray-400 block w-full p-2.5 rounded-l-lg py-3 px-4" placeholder="Username" /> +
+
+ +
+ +
+ setPassword(e.target.value)} placeholder="••••••••••" class="pl-12 mb-2 bg-gray-50 text-gray-600 border focus:border-transparent border-gray-300 sm:text-sm rounded-lg ring ring-transparent focus:ring-1 focus:outline-none focus:ring-gray-400 block w-full p-2.5 rounded-l-lg py-3 px-4" autocomplete="new-password" /> +
+
+ + +
Are you new around here? Sign Up + +
+
+
+ + + + {error && ( + setError('')} message={`Error: ${error}`} /> + )} +
-
); }; diff --git a/webapp/src/components/Navbar.jsx b/webapp/src/components/Navbar.jsx index 9726c12..8c92c81 100644 --- a/webapp/src/components/Navbar.jsx +++ b/webapp/src/components/Navbar.jsx @@ -12,22 +12,36 @@ function Navbar() { } return ( -
-
- WIQ -
- -
+ ) } diff --git a/webapp/src/components/Question.jsx b/webapp/src/components/Question.jsx index 55d93fa..6d143cb 100644 --- a/webapp/src/components/Question.jsx +++ b/webapp/src/components/Question.jsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import axios from "axios"; import useAuthUser from "react-auth-kit/hooks/useAuthUser"; +import ImgGameReport from "./ImgGameReport"; const Question = (props) => { const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; @@ -14,23 +15,33 @@ const Question = (props) => { const questionsPerGame = 10; const imagesPerQuestion = 4; + //Game Report + const [finished, setFinished] = useState(false); + const [answers, setAnswers] = useState([]); + + + useEffect(() => { fetchQuestions(); }, []); useEffect(() => { const interval = setInterval(() => { - if(renderedImages==imagesPerQuestion){ + if (renderedImages === imagesPerQuestion) { setCounter((prevCounter) => prevCounter + 0.4); - } + } }, 40); return () => clearInterval(interval); }, [renderedImages]); useEffect(() => { + async function answ() { + await answerQuestion("TimeOut1234;", questions[currentQuestion].question); + } + if (counter >= 100 && !loading) { - answerQuestion("",questions[currentQuestion]); + answ(); } }, [counter]); @@ -39,7 +50,7 @@ const Question = (props) => { try { setRenderedImages(0) let auxQuestions = [] - for(let i=0;i { try { setLoading(true); setRenderedImages(0) - if(currentQuestion>=questionsPerGame-1){ - fetchQuestions() - setCurrentQuestion(0) - setCounter(0); - return - } - - const result = await axios.post(`${apiEndpoint}/${props.type}/answer`, - { answer: answer, question:question, username: auth.username, category: props.category }, - { headers: {'Content-Type': 'application/json'}}); + - if ( result.data.correct === "true" ) { - setScore(score +1); + const result = await axios.post(`${apiEndpoint}/${props.type}/answer`, + { answer: answer, question: question, username: auth.username, category: props.category }, + { headers: { 'Content-Type': 'application/json' } }); + + if (result.data.correct === "true") { + setScore(score + 1); + setAnswers(answers.concat( {question:question,correct:result.data.correct,associate:answer})); + }else{ + setAnswers(answers.concat( {question:question,correct:result.data.correct,associate:result.data.correctImg})); + } + + if (currentQuestion >= questionsPerGame - 1) { + //Infinte Game + // fetchQuestions() + // setCurrentQuestion(0) + // setCounter(0); + setFinished(true); + setLoading(false); + return } - setCurrentQuestion((question)=>question+1) + setCurrentQuestion((question) => question + 1) setCounter(0); setLoading(false) } catch (error) { - console.log(error); + //console.log(error); } } - + const restartGame = async () => { + setLoading(true); + setScore(0); + setAnswers([]); + setCurrentQuestion(0); + setCounter(0); + setFinished(false); + await fetchQuestions(); + setLoading(false); + } + return ( + finished ? :
Score: {score} @@ -89,7 +119,7 @@ const Question = (props) => {
- ) : ( + ) : ( <>

{questions[currentQuestion].question}

@@ -99,9 +129,9 @@ const Question = (props) => {
{questions[currentQuestion].images.map(image => ( ))}
diff --git a/webapp/src/components/Squads.jsx b/webapp/src/components/Squads.jsx new file mode 100644 index 0000000..119e713 --- /dev/null +++ b/webapp/src/components/Squads.jsx @@ -0,0 +1,12 @@ +import React from 'react'; + +function Squads() { + return ( +
+

Squads

+

Coming soon...

+
+ ); +} + +export default Squads; \ No newline at end of file diff --git a/webapp/src/components/ranking/RankingLayout.jsx b/webapp/src/components/ranking/RankingLayout.jsx index 666b88e..50ffece 100644 --- a/webapp/src/components/ranking/RankingLayout.jsx +++ b/webapp/src/components/ranking/RankingLayout.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState } from "react"; import RankingsTable from "./RankingTable"; const RankingsLayout = () => {