diff --git a/frontend/src/components/Quiz.tsx b/frontend/src/components/Quiz.tsx
index a21ad8c75..720af3ee5 100644
--- a/frontend/src/components/Quiz.tsx
+++ b/frontend/src/components/Quiz.tsx
@@ -69,6 +69,7 @@ const Quiz = () => {
//showScore allows us to see the final summary at the very end, once the questions list is exhausted
const [currentQuestion, setCurrentQuestion] = useState(0);
const [showScore, setShowScore] = useState(false);
+
const handleAnswerButtonClick = (
answerText: string,
currentQuestion: number
@@ -93,6 +94,7 @@ const Quiz = () => {
const nextQuestions = currentQuestion + 1;
console.log(nextQuestions);
+
if (nextQuestions < questions.length) {
setCurrentQuestion(nextQuestions);
} else {
@@ -100,6 +102,14 @@ const Quiz = () => {
}
};
+ //Local storage hook for remembering answers. Seems to work but current bug relating to the displaying of answers results in duplicate answers
+ React.useEffect(() => {
+ localStorage.setItem("leastImp", JSON.stringify(leastImp));
+ localStorage.setItem("lessImp", JSON.stringify(lessImp));
+ localStorage.setItem("imp", JSON.stringify(imp));
+ localStorage.setItem("moreImp", JSON.stringify(moreImp));
+ }, [leastImp, lessImp, imp, moreImp]);
+
const showLeast = () => leastImp.map((item) =>
{item});
const showLess = () => lessImp.map((item) => {item});
const showImp = () => imp.map((item) => {item});
diff --git a/frontend/src/components/Select/Select.tsx b/frontend/src/components/Select/Select.tsx
index 8c45d668c..6992ab46b 100644
--- a/frontend/src/components/Select/Select.tsx
+++ b/frontend/src/components/Select/Select.tsx
@@ -5,18 +5,24 @@ import MenuItem from "@mui/material/MenuItem";
import Select, { SelectChangeEvent } from "@mui/material/Select";
export default function BasicSelect() {
- const [age, setAge] = React.useState("English");
+ const [lang, setlang] = React.useState("English");
const handleChange = (event: SelectChangeEvent) => {
- setAge(event.target.value as string);
+ setlang(event.target.value as string);
};
//Used for the dropdown button in the navigation menu, to be a trigger for Strapi content, i.e. when Spanish selected, switches to Spanish version, etc.
+
+ //Localstorage
+ React.useEffect(() => {
+ localStorage.setItem("selectedLanguage", lang);
+ }, [lang]);
+
return (