diff --git a/frontend/src/components/form/answerbox/AnswerBox.svelte b/frontend/src/components/form/answerbox/AnswerBox.svelte index 79a35c5..033c4e8 100644 --- a/frontend/src/components/form/answerbox/AnswerBox.svelte +++ b/frontend/src/components/form/answerbox/AnswerBox.svelte @@ -15,7 +15,7 @@ let helpfulness:string const handleFormUpdate = () => { - if (knowledge != "" && empathy != "" && helpfulness != "") { + if (knowledge && empathy && helpfulness) { dispatch("update", true) } diff --git a/frontend/src/components/form/footer/Footer.svelte b/frontend/src/components/form/footer/Footer.svelte index ca795a9..f3effa5 100644 --- a/frontend/src/components/form/footer/Footer.svelte +++ b/frontend/src/components/form/footer/Footer.svelte @@ -24,7 +24,7 @@ class={`${questionNum == 0 || questionNum % 4 != 0 ? "hidden" : "bg-primary text-bg hover:bg-bg hover:text-primary"} font-bold uppercase border-primary border-2 rounded-full px-8 py-3`}> Send inn svar - diff --git a/frontend/src/lib/convertAnswerData.ts b/frontend/src/lib/convertAnswerData.ts index a21aa30..a4d87c6 100644 --- a/frontend/src/lib/convertAnswerData.ts +++ b/frontend/src/lib/convertAnswerData.ts @@ -18,7 +18,6 @@ export const convertAnswerDataToNumeric = (value: string): number => { result = 5; break; default: - console.log("Wrong input"); result = 0; break; } @@ -46,7 +45,6 @@ export const convertAnswerDataToString = (value: number): string => { result = "Veldig bra"; break; default: - console.log("Wrong input"); break; } diff --git a/frontend/src/routes/form/[slug]/+page.svelte b/frontend/src/routes/form/[slug]/+page.svelte index af9ba96..ee9b42a 100644 --- a/frontend/src/routes/form/[slug]/+page.svelte +++ b/frontend/src/routes/form/[slug]/+page.svelte @@ -34,6 +34,27 @@ questionAnswer2Text = questions[questionNumber].Answers[1].AnswerText; questionAnswer2ID = questions[questionNumber].Answers[1].AnswerID; } + + let allFormAnswers:string | null = localStorage.getItem("allFormAnswers") + + if (allFormAnswers) { + let existingFormAnswers = JSON.parse(allFormAnswers); + let retrievedFormAnswers:Map = new Map(existingFormAnswers) + let formAnswer1 = retrievedFormAnswers.get(questionAnswer1ID) + let formAnswer2 = retrievedFormAnswers.get(questionAnswer2ID) + if (formAnswer1 && formAnswer2) { + if (formAnswer1.includes(0) || formAnswer2.includes(0)) { + question1Answered = false + question2Answered = false + } else { + question1Answered = true + question2Answered = true + } + } else { + question1Answered = false + question2Answered = false + } + } } // On mount, call the update function