🚧 working on submitting form
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
e3a6ff55b4
commit
6a3f5cf825
4 changed files with 42 additions and 6 deletions
|
@ -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()
|
||||
|
|
|
@ -8,7 +8,7 @@ export const postUserformData = (
|
|||
healthcare_personnel: string,
|
||||
gender: string
|
||||
): Promise<postUserformDataReponse> => {
|
||||
let url = "http://localhost:8080/submitform";
|
||||
let url = "http://localhost:8080/submituserform";
|
||||
let personnel = healthcare_personnel == "Ja" ? true : false;
|
||||
|
||||
const response = fetch(url, {
|
||||
|
|
|
@ -1,8 +1,35 @@
|
|||
<script lang="ts">
|
||||
import UserFormInput from "../../userform/UserFormInput.svelte";
|
||||
|
||||
import { convertAnswerData } from "$lib/convertAnswerData";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let answerText:string
|
||||
export let answerNum:number
|
||||
let answeredAll:boolean
|
||||
|
||||
let knowledge:string
|
||||
let empathy:string
|
||||
let helpfulness:string
|
||||
|
||||
const handleFormUpdate = (category:string, value:string) => {
|
||||
if (knowledge != "" && empathy != "" && helpfulness != "") {
|
||||
answeredAll = true
|
||||
}
|
||||
|
||||
let numericValue = convertAnswerData(value)
|
||||
switch (category) {
|
||||
case "knowledge":
|
||||
knowledge = numericValue
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
knowledge=""
|
||||
empathy=""
|
||||
helpfulness=""
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -14,8 +41,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col justify-start items-center gap-6">
|
||||
<UserFormInput inputType="radio" label="Kunnskap" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
|
||||
<UserFormInput inputType="radio" label="Empati" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
|
||||
<UserFormInput inputType="radio" label="Hjelpsomhet" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
|
||||
<UserFormInput formData={knowledge} on:update={(e) => knowledge = e.detail} inputType="radio" label="Kunnskap" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
|
||||
<UserFormInput formData={empathy} on:update={(e) => empathy = e.detail} inputType="radio" label="Empati" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
|
||||
<UserFormInput formData={helpfulness} on:update={(e) => helpfulness = e.detail} inputType="radio" label="Hjelpsomhet" options={["Veldig dårlig", "Dårlig", "Nøytral", "Bra", "Veldig bra"]}/>
|
||||
</div>
|
||||
</div>
|
|
@ -1,5 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
function handleFormChange(selectedValue: string) {
|
||||
dispatch('update', selectedValue);
|
||||
|
|
Reference in a new issue