🚧 working on test evaluation
Co-authored-by: haraldnilsen <harald_998@hotmail.com> Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
113b0fb4b7
commit
ed474d4433
4 changed files with 129 additions and 0 deletions
20
frontend/src/api/postEvaluationData.ts
Normal file
20
frontend/src/api/postEvaluationData.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
export const postEvaluationData = (evaluationText: string) => {
|
||||
let url = "http://localhost:8080/submiteval";
|
||||
|
||||
const response = fetch(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
evaluationText: evaluationText,
|
||||
}),
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
return response.ok;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
return response;
|
||||
};
|
35
frontend/src/routes/evaluation/+page.svelte
Normal file
35
frontend/src/routes/evaluation/+page.svelte
Normal file
|
@ -0,0 +1,35 @@
|
|||
<script lang="ts">
|
||||
import { postEvaluationData } from "../../api/postEvaluationData";
|
||||
import { goto } from "$app/navigation";
|
||||
|
||||
let evaluationText:string = ""
|
||||
|
||||
const handleEvaluationSubmit = () => {
|
||||
if (evaluationText) {
|
||||
postEvaluationData(evaluationText)
|
||||
goto("/")
|
||||
} else {
|
||||
console.log("error");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col justify-between items-center h-full">
|
||||
<div class="flex flex-col gap-8 h-full mt-8">
|
||||
<div class="flex flex-col gap-4 px-96 items-center">
|
||||
<h1 class="text-3xl text-primary font-bold">Takk for at du tok deg tid!</h1>
|
||||
<p>Tusen takk for hjelpen i denne undersøkelsen! Vi setter stor pris på det og håper du får en fin dag videre.</p>
|
||||
<p>Har du tid så setter vi veldig pris på om du skrevet en liten tilbakemelding til oss i tekstfeltet under:</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-4 justify-center items-center">
|
||||
<textarea bind:value={evaluationText} cols="30" rows="8" class="border-solid border-gray-400 border-2 p-3 md:text-l w-1/3" placeholder="Skriv evaluering her"></textarea>
|
||||
<button
|
||||
class="text-primary hover:bg-primary hover:text-bg font-bold border-primary border-2 rounded-full px-8 py-1"
|
||||
on:click={handleEvaluationSubmit}
|
||||
>
|
||||
Send evaluering
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Reference in a new issue