🚧 started on question-form

Co-authored-by: haraldnilsen <harald_998@hotmail.com>
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
Sindre Kjelsrud 2024-01-04 18:23:45 +01:00
parent 8e4e7aa5fc
commit 7e00f24fbd
Signed by untrusted user who does not match committer: sidski
GPG key ID: D2BBDF3EDE6BA9A6
3 changed files with 17 additions and 5 deletions

View file

@ -71,7 +71,9 @@ func GetUserQuestions(respondentID int) ([]UserQuestions, error) {
return questionAnswers, err return questionAnswers, err
} }
getAnswersStatement := `WITH TrueAnswer AS ( getAnswersStatement :=
`
WITH TrueAnswer AS (
SELECT ss.svarID SELECT ss.svarID
FROM SpørsmålSvar ss FROM SpørsmålSvar ss
WHERE ss.spørsmålID = $1 WHERE ss.spørsmålID = $1

View file

@ -1,9 +1,13 @@
export const postFormData = ( interface postUserformDataReponse {
respondentID: number;
}
export const postUserformData = (
age: string, age: string,
education: string, education: string,
healthcare_personnel: string, healthcare_personnel: string,
gender: string gender: string
) => { ): postUserformDataReponse => {
let url = "http://localhost:8080/submitform"; let url = "http://localhost:8080/submitform";
let personnel = healthcare_personnel == "Ja" ? true : false; let personnel = healthcare_personnel == "Ja" ? true : false;

View file

@ -2,12 +2,18 @@
import UserFormInput from "../../components/userform/UserFormInput.svelte"; import UserFormInput from "../../components/userform/UserFormInput.svelte";
import ArrowBack from "../../components/svg/ArrowBack.svelte"; import ArrowBack from "../../components/svg/ArrowBack.svelte";
import ButtonComponent from "../../components/userform/inputs/ButtonComponent.svelte"; import ButtonComponent from "../../components/userform/inputs/ButtonComponent.svelte";
import { postFormData } from "../../api/postFormData"; import { postUserformData } from "../../api/postUserformData";
let age: string = "18-20" let age: string = "18-20"
let education: string = "PhD" let education: string = "PhD"
let healthcare_personnel: string = "Ja" let healthcare_personnel: string = "Ja"
let gender: string = "Mann" let gender: string = "Mann"
const handleUserformSubmit = async (age: string, education: string, healthcare_personnel: string, gender: string) => {
const response = await postUserformData(age, education, healthcare_personnel, gender)
await getUserQuestions(response.respondentID)
}
</script> </script>
<div class="flex flex-col justify-center gap-20 h-full "> <div class="flex flex-col justify-center gap-20 h-full ">
@ -28,7 +34,7 @@
</div> </div>
</div> </div>
<div class="flex justify-center items-center gap-8 text-primary font-bold"> <div class="flex justify-center items-center gap-8 text-primary font-bold">
<ButtonComponent text="Start undersøkelse" url="/form" filled={true} onclick={() => postFormData(age, education, healthcare_personnel, gender)} /> <ButtonComponent text="Start undersøkelse" url="/form" filled={true} onclick={() => handleUserformSubmit(age, education, healthcare_personnel, gender)} />
</div> </div>
</div> </div>