aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-11-09 11:18:38 -0800
committerAdam Soltys <[email protected]>2022-11-09 11:18:38 -0800
commitc901b229121ee74b4a1a8794ca7578d9cfea0055 (patch)
treebb8192035e7076ffae126a6596088d96402768a4 /src/routes
parent305f26ccefffe52b3fb65995e8caf437f1a92057 (diff)
downloadcoinos-ui-c901b229121ee74b4a1a8794ca7578d9cfea0055.tar.gz
coinos-ui-c901b229121ee74b4a1a8794ca7578d9cfea0055.zip
fix support form
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/support/+page.server.js (renamed from src/routes/(app)/[username]/support/+page.server.js)5
-rw-r--r--src/routes/(app)/support/+page.svelte (renamed from src/routes/(app)/[username]/support/+page.svelte)11
2 files changed, 12 insertions, 4 deletions
diff --git a/src/routes/(app)/[username]/support/+page.server.js b/src/routes/(app)/support/+page.server.js
index a335ec96..78c640e3 100644
--- a/src/routes/(app)/[username]/support/+page.server.js
+++ b/src/routes/(app)/support/+page.server.js
@@ -1,3 +1,6 @@
+import { post } from "$lib/utils";
+import { invalid } from '@sveltejs/kit';
+
export const actions = {
default: async ({ cookies, request }) => {
let form = Object.fromEntries(await request.formData());
@@ -5,7 +8,7 @@ export const actions = {
try {
await post('/email', form);
} catch (e) {
- return invalid(400, { failed: true });
+ return invalid(400, { error: e.message });
}
return { success: true };
diff --git a/src/routes/(app)/[username]/support/+page.svelte b/src/routes/(app)/support/+page.svelte
index cd1cc69f..9181f701 100644
--- a/src/routes/(app)/[username]/support/+page.svelte
+++ b/src/routes/(app)/support/+page.svelte
@@ -11,12 +11,18 @@
let message;
</script>
+{#if form?.error}
+ <div class="text-red-600 text-center">
+ {form.error}
+ </div>
+{/if}
+
<div class="container px-4 max-w-lg mx-auto mt-20">
{#if form?.success}
<h1 class="text-center text-3xl md:text-4xl font-semibold mb-8">Thank you!</h1>
<p class="text-center mb-8">Someone will be in touch shortly.</p>
- <a href={`/${user.username}/dashboard`}>
+ <a href={user ? `/${user.username}/dashboard` : '/'}>
<button class="rounded-full border py-2 px-5 font-bold hover:opacity-80 w-full mb-2"
>Done</button
>
@@ -33,8 +39,7 @@
type="text"
name="account"
required
- disabled
- value={user.username}
+ value={user?.username || ''}
/>
</div>