From 0c1e843f08543b4394aa5bfed3528910c26cb1b7 Mon Sep 17 00:00:00 2001 From: c0repwn3r Date: Tue, 21 Feb 2023 11:32:26 -0500 Subject: [PATCH] some more routes and i18n stuff --- tfweb/src/lib/i18n/en.json | 19 +++- tfweb/src/routes/auth/login/+page.svelte | 17 +++ tfweb/src/routes/auth/magic-link/+page.svelte | 17 +++ tfweb/src/routes/signup/+page.svelte | 101 ++++++++++++++++++ 4 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 tfweb/src/routes/auth/magic-link/+page.svelte create mode 100644 tfweb/src/routes/signup/+page.svelte diff --git a/tfweb/src/lib/i18n/en.json b/tfweb/src/lib/i18n/en.json index a93c64c..440364e 100644 --- a/tfweb/src/lib/i18n/en.json +++ b/tfweb/src/lib/i18n/en.json @@ -15,8 +15,25 @@ "subtitle": "We'll send you an email with a \"magic link\".", "prompt": "What's your email?", "actionButtonText": "Log in", + "createaccount": "create an account", "apierror": { - "authorization was provided but it is expired or invalid": "User does not exist, maybe consider creating an account?" + "authorization was provided but it is expired or invalid": "User does not exist, maybe consider creating an account?", + "xhrerror": "unable to contact server, please try again later" } + }, + + "signup": { + "title": "Get started with trifid", + "subtitle": "Simply manage connectivity between hosts running any major OS.", + "prompt": "What is your email address?", + "actionButtonText": "Create account", + "login": "Already have an account?", + "sentMagicLink": "Check your email!", + "magicLinkExplainer": "We sent you a link, click on it to finish creating your account." + }, + + "magiclink": { + "loadtitle": "Verifying magic link...", + "loadsubtitle": "Hang on while we check this link." } } \ No newline at end of file diff --git a/tfweb/src/routes/auth/login/+page.svelte b/tfweb/src/routes/auth/login/+page.svelte index bb0b9e8..1ab147a 100644 --- a/tfweb/src/routes/auth/login/+page.svelte +++ b/tfweb/src/routes/auth/login/+page.svelte @@ -15,12 +15,19 @@ isloading = true; let xhr = new XMLHttpRequest(); + xhr.timeout = 10000; xhr.open('POST', `${API_ROOT}/v1/auth/magic-link`); xhr.setRequestHeader("Content-Type", "application/json"); xhr.send(JSON.stringify({ email: email })); + xhr.ontimeout = () => { + hasError = true; + error = t('login.apierror.timeout'); + isloading = false; + }; + xhr.onload = () => { if (xhr.status != 200) { // error @@ -35,6 +42,12 @@ isFinished = true; } }; + + xhr.onerror = () => { + hasError = true; + error = t('login.apierror.xhrerror'); + isloading = false; + }; } @@ -71,6 +84,10 @@ {/if} + +
+ {t('login.createaccount')} +
{:else} diff --git a/tfweb/src/routes/auth/magic-link/+page.svelte b/tfweb/src/routes/auth/magic-link/+page.svelte new file mode 100644 index 0000000..029c025 --- /dev/null +++ b/tfweb/src/routes/auth/magic-link/+page.svelte @@ -0,0 +1,17 @@ + + +
+
+ {#if isLoading} +
+

{t('magiclink.loadtitle')}

+

{t('magiclink.loadsubtitle')}

+
+ {/if} +
+
\ No newline at end of file diff --git a/tfweb/src/routes/signup/+page.svelte b/tfweb/src/routes/signup/+page.svelte new file mode 100644 index 0000000..28da669 --- /dev/null +++ b/tfweb/src/routes/signup/+page.svelte @@ -0,0 +1,101 @@ + + +
+
+ {#if !isFinished} + +
+

{t('signup.title')}

+

{t('signup.subtitle')}

+
+ + +
+
+ + + {#if hasError} + {error} + {/if} +
+ + + + + +
+ {:else} + +
+

{t('signup.sentMagicLink')}

+

{t('signup.magicLinkExplainer')}

+
+ {/if} +
+
\ No newline at end of file