🚧 working on submit
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
b732a46ca1
commit
7ffea02700
4 changed files with 23 additions and 4 deletions
|
@ -15,7 +15,7 @@
|
|||
let helpfulness:string
|
||||
|
||||
const handleFormUpdate = () => {
|
||||
if (knowledge != "" && empathy != "" && helpfulness != "") {
|
||||
if (knowledge && empathy && helpfulness) {
|
||||
dispatch("update", true)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
</button>
|
||||
<button disabled={(questionNum != 0 && questionNum % 4 == 0) || !answeredAll} class={`flex items-center gap-2 text-primary font-semibold ${questionNum != 0 && questionNum % 4 == 0 && "opacity-50"}`} on:click={() => gotoNextPage(questionNum)}>
|
||||
<button disabled={(questionNum != 0 && questionNum % 4 == 0) || !answeredAll} class={`flex items-center gap-2 text-primary font-semibold ${(questionNum != 0 && questionNum % 4 == 0) || !answeredAll && "opacity-50"}`} on:click={() => gotoNextPage(questionNum)}>
|
||||
Neste spørsmål
|
||||
<ArrowChevron width=16 direction="right"/>
|
||||
</button>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<number, number[]> = 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
|
||||
|
|
Reference in a new issue