2021-07-31 23:06:14 +03:00
|
|
|
<script context="module">
|
|
|
|
|
export function preload(page, { config }) {
|
|
|
|
|
return { config };
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2021-04-05 07:12:51 +03:00
|
|
|
<script>
|
2021-08-18 19:47:02 +03:00
|
|
|
import { Chasing } from 'svelte-loading-spinners';
|
2021-07-26 02:31:00 +03:00
|
|
|
import TextField from '../components/Form/TextField.svelte';
|
|
|
|
|
import PrimaryButton from '../components/PrimaryButton/index.svelte';
|
2021-07-31 23:06:14 +03:00
|
|
|
import { getSupabase } from '../utils/functions/supabase';
|
2021-08-18 19:47:02 +03:00
|
|
|
import { user } from '../utils/store/user';
|
2021-07-26 02:31:00 +03:00
|
|
|
|
2021-07-31 23:06:14 +03:00
|
|
|
export let config;
|
|
|
|
|
|
|
|
|
|
let supabase = getSupabase(config);
|
2021-07-26 02:31:00 +03:00
|
|
|
let email;
|
2021-07-31 23:06:14 +03:00
|
|
|
let loading = false;
|
|
|
|
|
let success = false;
|
|
|
|
|
let errors = {};
|
2021-07-26 02:31:00 +03:00
|
|
|
|
2021-07-31 23:06:14 +03:00
|
|
|
async function handleSubmit() {
|
|
|
|
|
if (!email) {
|
|
|
|
|
errors = {
|
|
|
|
|
email: 'Email is required',
|
|
|
|
|
};
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
loading = true;
|
|
|
|
|
const { data, error } = await supabase.auth.signIn(
|
|
|
|
|
{ email },
|
|
|
|
|
{
|
|
|
|
|
redirectTo: window.location.origin + '/login',
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
if (error) throw error;
|
|
|
|
|
|
|
|
|
|
success = true;
|
|
|
|
|
email = {};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
errors = {
|
|
|
|
|
email: error.error_description || error.message,
|
|
|
|
|
};
|
|
|
|
|
} finally {
|
|
|
|
|
loading = false;
|
|
|
|
|
}
|
2021-04-05 07:12:51 +03:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2021-01-21 22:26:32 +02:00
|
|
|
<svelte:head>
|
2021-06-01 07:19:19 +03:00
|
|
|
<title>Join ClassroomIO</title>
|
2021-01-21 22:26:32 +02:00
|
|
|
</svelte:head>
|
|
|
|
|
|
2021-07-26 02:31:00 +03:00
|
|
|
<div class="w-full h-screen flex items-center justify-center ">
|
|
|
|
|
<div class="container border border-gray-300 rounded-md p-12">
|
|
|
|
|
<form
|
|
|
|
|
on:submit|preventDefault={handleSubmit}
|
|
|
|
|
class="flex items-center flex-col w-full"
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src="/logo-192.png"
|
|
|
|
|
alt="ClassroomIO logo"
|
|
|
|
|
height="70"
|
|
|
|
|
width="70"
|
|
|
|
|
data-atf="1"
|
|
|
|
|
/>
|
|
|
|
|
<h4 class="text-lg m-0 mt-3">Login</h4>
|
|
|
|
|
<p class="text-sm">into ClassroomIO</p>
|
|
|
|
|
|
|
|
|
|
<div class="my-4 w-full">
|
2021-08-18 19:47:02 +03:00
|
|
|
{#if $user.fetchingUser}
|
|
|
|
|
<div class="h-40 text-md flex items-center justify-center">
|
|
|
|
|
<Chasing size="60" color="#ff3e00" unit="px" duration="1s" />
|
|
|
|
|
</div>
|
|
|
|
|
{:else if success}
|
|
|
|
|
<div class="h-40 text-md flex items-center justify-center flex-col">
|
|
|
|
|
<p class="">
|
|
|
|
|
A link has been sent to your email. Please check both your
|
|
|
|
|
<strong>spam</strong>and your<strong>inbox</strong>.
|
|
|
|
|
</p>
|
|
|
|
|
<p class="mt-2 underline">
|
|
|
|
|
If our email is in your spam, do make sure you mark our email
|
|
|
|
|
address as safe, then move it from your spam to your inbox.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2021-07-31 23:06:14 +03:00
|
|
|
{:else}
|
|
|
|
|
<TextField
|
2021-08-18 19:47:02 +03:00
|
|
|
label="Email address"
|
2021-07-31 23:06:14 +03:00
|
|
|
bind:value={email}
|
|
|
|
|
type="email"
|
|
|
|
|
autoFocus={true}
|
2021-08-18 19:47:02 +03:00
|
|
|
placeholder="you@domain.com"
|
2021-07-31 23:06:14 +03:00
|
|
|
inputClassName="rounded-md w-full px-2 py-4"
|
|
|
|
|
isDisabled={loading}
|
|
|
|
|
errorMessage={errors.email}
|
|
|
|
|
/>
|
2021-08-18 19:47:02 +03:00
|
|
|
<p class="py-3 text-md">
|
2021-07-31 23:06:14 +03:00
|
|
|
A magic link will be sent to your email, please open the link
|
|
|
|
|
</p>
|
|
|
|
|
{/if}
|
2021-07-26 02:31:00 +03:00
|
|
|
</div>
|
|
|
|
|
|
2021-08-18 19:47:02 +03:00
|
|
|
{#if !success}
|
|
|
|
|
<div class="my-4 w-full flex justify-between items-center">
|
|
|
|
|
<a href="/signup" class="text-blue-700 text-sm">Create an account</a>
|
|
|
|
|
<PrimaryButton
|
|
|
|
|
label={loading ? 'Creating...' : 'Next'}
|
|
|
|
|
type="submit"
|
|
|
|
|
className="py-2 px-4"
|
|
|
|
|
isDisabled={loading}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2021-07-26 02:31:00 +03:00
|
|
|
</form>
|
|
|
|
|
</div>
|
2021-06-01 07:19:19 +03:00
|
|
|
</div>
|
2021-07-26 02:31:00 +03:00
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.container {
|
|
|
|
|
width: 450px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|