From 6a3f5cf8250347bc77a2e9a0ee5229b1ade54b39 Mon Sep 17 00:00:00 2001 From: haraldnilsen Date: Sun, 7 Jan 2024 13:59:07 +0100 Subject: [PATCH] :construction: working on submitting form Co-authored-by: Sindre Kjelsrud --- backend/cmd/main.go | 10 +++++- frontend/src/api/postUserformData.ts | 2 +- .../form/answerbox/AnswerBox.svelte | 35 ++++++++++++++++--- .../components/userform/UserFormInput.svelte | 1 + 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/backend/cmd/main.go b/backend/cmd/main.go index 47e38b1..0688b2e 100644 --- a/backend/cmd/main.go +++ b/backend/cmd/main.go @@ -23,7 +23,7 @@ func main() { router.Use(cors.Default()) // Info about user - router.POST("/submitform", func(c *gin.Context) { + router.POST("/submituserform", func(c *gin.Context) { var requestBody FormData @@ -65,6 +65,14 @@ func main() { c.JSON(http.StatusOK, gin.H{"questions": questions}) }) + router.POST("/submitanswers", func(c *gin.Context) { + var requestBody FormData + + if err := c.BindJSON(&requestBody); err != nil { + fmt.Print(err) + } + }) + // Run the server on port 8080 router.Run(":8080") //db.SetupDb() diff --git a/frontend/src/api/postUserformData.ts b/frontend/src/api/postUserformData.ts index 3adc5bf..b7f0d4e 100644 --- a/frontend/src/api/postUserformData.ts +++ b/frontend/src/api/postUserformData.ts @@ -8,7 +8,7 @@ export const postUserformData = ( healthcare_personnel: string, gender: string ): Promise => { - let url = "http://localhost:8080/submitform"; + let url = "http://localhost:8080/submituserform"; let personnel = healthcare_personnel == "Ja" ? true : false; const response = fetch(url, { diff --git a/frontend/src/components/form/answerbox/AnswerBox.svelte b/frontend/src/components/form/answerbox/AnswerBox.svelte index 71fb17e..7b39911 100644 --- a/frontend/src/components/form/answerbox/AnswerBox.svelte +++ b/frontend/src/components/form/answerbox/AnswerBox.svelte @@ -1,8 +1,35 @@ @@ -14,8 +41,8 @@
- - - + knowledge = e.detail} inputType="radio" label="Kunnskap" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/> + empathy = e.detail} inputType="radio" label="Empati" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/> + helpfulness = e.detail} inputType="radio" label="Hjelpsomhet" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
\ No newline at end of file diff --git a/frontend/src/components/userform/UserFormInput.svelte b/frontend/src/components/userform/UserFormInput.svelte index 49a4a50..42c3244 100644 --- a/frontend/src/components/userform/UserFormInput.svelte +++ b/frontend/src/components/userform/UserFormInput.svelte @@ -1,5 +1,6 @@