🚧 working on submit-functionality
Co-authored-by: haraldnilsen <harald_998@hotmail.com> Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
d92c45ecfc
commit
b732a46ca1
3 changed files with 14 additions and 8 deletions
|
|
@ -2,12 +2,13 @@
|
|||
import UserFormInput from "../../userform/UserFormInput.svelte";
|
||||
import { convertAnswerDataToNumeric, convertAnswerDataToString } from "$lib/convertAnswerData";
|
||||
import { onMount } from "svelte";
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let answerText:string
|
||||
export let answerNum:number
|
||||
export let answerID:number
|
||||
|
||||
let answeredAll:boolean
|
||||
|
||||
let knowledge:string
|
||||
let empathy:string
|
||||
|
|
@ -15,7 +16,7 @@
|
|||
|
||||
const handleFormUpdate = () => {
|
||||
if (knowledge != "" && empathy != "" && helpfulness != "") {
|
||||
answeredAll = true
|
||||
dispatch("update", true)
|
||||
}
|
||||
|
||||
let knowledgeNumeric = convertAnswerDataToNumeric(knowledge)
|
||||
|
|
@ -56,7 +57,6 @@
|
|||
empathy=""
|
||||
helpfulness=""
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
import { goto } from "$app/navigation";
|
||||
|
||||
export let questionNum:number
|
||||
export let answeredAll:boolean
|
||||
|
||||
const gotoNextPage = async (questionNum: number) => {
|
||||
goto(`${questionNum + 1}`)
|
||||
|
|
@ -23,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} 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 && "opacity-50"}`} on:click={() => gotoNextPage(questionNum)}>
|
||||
Neste spørsmål
|
||||
<ArrowChevron width=16 direction="right"/>
|
||||
</button>
|
||||
|
|
|
|||
Reference in a new issue