✨ reportbug is "finished"
just need to update database! Co-authored-by: haraldnilsen <harald_998@hotmail.com> Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
deb7d05b98
commit
113b0fb4b7
6 changed files with 135 additions and 17 deletions
20
frontend/src/api/postBugData.ts
Normal file
20
frontend/src/api/postBugData.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
export const postBugData = (bugText: string) => {
|
||||
let url = "http://localhost:8080/submitbug";
|
||||
|
||||
const response = fetch(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
bugText: bugText,
|
||||
}),
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||
}
|
||||
return response.ok;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
return response;
|
||||
};
|
|
@ -13,7 +13,7 @@
|
|||
<p class="text-sm">{formQuestion}</p>
|
||||
</div>
|
||||
<div class="flex justify-end pr-20 items-center w-1/3">
|
||||
<a class="-" href="/reporterror">
|
||||
<a class="-" href="/reportbug">
|
||||
<CircleExclamation width="16" height="16" />
|
||||
</a>
|
||||
</div>
|
||||
|
|
40
frontend/src/routes/reportbug/+page.svelte
Normal file
40
frontend/src/routes/reportbug/+page.svelte
Normal file
|
@ -0,0 +1,40 @@
|
|||
<script lang="ts">
|
||||
import { postBugData } from "../../api/postBugData";
|
||||
import { goto } from "$app/navigation";
|
||||
|
||||
let bugText:string = ""
|
||||
|
||||
const handleBugSubmit = () => {
|
||||
if (bugText) {
|
||||
postBugData(bugText)
|
||||
goto("javascript:history.back()")
|
||||
} else {
|
||||
console.log("error");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col justify-between items-center h-full">
|
||||
<div class="flex flex-col gap-4 h-full mt-8">
|
||||
<div class="flex flex-col gap-4 px-96 items-center">
|
||||
<h1 class="text-3xl text-primary font-bold">Å nei!</h1>
|
||||
<p>Har du funnet feil eller mangler, eller er det noe du ønsker å melde i fra om angående spørreundersøkelsen? Skriv det i tekstfeltet under. (Dette er selvfølgelig helt anonymt også!)</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-4 justify-center items-center">
|
||||
<textarea bind:value={bugText} cols="30" rows="8" class="border-solid border-gray-400 border-2 p-3 md:text-l w-1/3" placeholder="Skriv feil 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={handleBugSubmit}
|
||||
>
|
||||
Send feil
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="flex justify-center items-center gap-8 text-primary font-bold">
|
||||
<!-- svelte-ignore a11y-invalid-attribute -->
|
||||
<button><a href="javascript:history.back()">Tilbake</a></button>
|
||||
</div>
|
||||
</div>
|
|
@ -1,16 +0,0 @@
|
|||
<div class="flex flex-col justify-between items-center h-full">
|
||||
<div class="flex h-full mt-8">
|
||||
<div class="flex flex-col items-center">
|
||||
<h1 class="text-3xl text-primary font-bold">Å nei!</h1>
|
||||
<p>Har du funnet feil eller mangler, eller er det noe du ønsker å melde i fra om angående spørreundersøkelsen? Skriv det i tekstfeltet under.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<form>
|
||||
<input type="text"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="flex justify-center items-center gap-8 text-primary font-bold">
|
||||
<button><a href="/">Tilbake</a></button>
|
||||
</div>
|
||||
</div>
|
Reference in a new issue