diff --git a/src/lib/navigation/done.svelte b/src/lib/navigation/done.svelte new file mode 100644 index 0000000..c720481 --- /dev/null +++ b/src/lib/navigation/done.svelte @@ -0,0 +1,31 @@ +
+

+

Done

+
+ + \ No newline at end of file diff --git a/src/routes/more/report/+page.svelte b/src/routes/more/report/+page.svelte index 49ef2cc..aff139d 100644 --- a/src/routes/more/report/+page.svelte +++ b/src/routes/more/report/+page.svelte @@ -4,9 +4,12 @@ import Nav from "$lib/navigation/nav.svelte"; import { onMount } from "svelte"; import Loading from "$lib/navigation/loading.svelte"; + import Done from "$lib/navigation/done.svelte"; const title = "Report Issue"; let isLoading = false; + let isDone = false; + let isError = false; let reportType = "", reportSubject = "", reportMsg = "", reportCollected onMount(async () => { @@ -30,7 +33,7 @@ console.log("SEND DATA REQUESTED") isLoading = true const formData = JSON.stringify({ - labels: [reportType], + label: reportType, subject: reportSubject, msg: `User Agent: ${reportCollected.userAgent}\n` + `Browser: ${reportCollected.browser}\n` + @@ -43,14 +46,28 @@ const url = `https://owlboard.info/misc/issue` const options = { method: "POST", + headers: { + "Content-Type": "application/json" + }, body: formData } const res = await fetch(url, options) - console.log(formData) + if (res.status == 200) { + isLoading = false; + isDone = true; + await new Promise(r => setTimeout(r, 2000)); + window.location.href = "/"; + } else { + isLoading = false; + isError = true; + } } async function cancel() { preFlight = false; + isLoading = false; + isDone = false; + isError = false; } @@ -60,13 +77,18 @@ {/if} -{#if !preFlight} +{#if isDone} + +{/if} + +{#if !preFlight && !isDone}

Any data that you enter here will be visible publicly here

You will be shown all of the collected data before the form is submitted.