mirror of
https://github.com/jcreek/SvelteKitSaasBoilerplate.git
synced 2026-07-12 18:43:50 +00:00
feat(#35): schedule toast rather than display text
This commit is contained in:
@@ -1,20 +1,18 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { scheduleToast } from '$lib/stores/toastStore.js';
|
||||||
export let supabase: any;
|
export let supabase: any;
|
||||||
|
const SUCCESS_MESSAGE = 'Check your email for the magic link.';
|
||||||
|
|
||||||
let error = '',
|
let loading = false,
|
||||||
message = '',
|
|
||||||
loading = false,
|
|
||||||
email = '';
|
email = '';
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
error = '';
|
|
||||||
message = '';
|
|
||||||
loading = true;
|
loading = true;
|
||||||
|
|
||||||
const { error: err } = await supabase.auth.signInWithOtp({ email });
|
const { error: err } = await supabase.auth.signInWithOtp({ email });
|
||||||
|
|
||||||
if (err) error = err.message;
|
if (err) scheduleToast(err.message, 'error', 5000);
|
||||||
else message = 'Check your email for the magic link.';
|
else scheduleToast(SUCCESS_MESSAGE, 'success', 5000);
|
||||||
|
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
@@ -37,18 +35,6 @@
|
|||||||
<button class="btn btn-active btn-primary w-full" on:click disabled={loading}
|
<button class="btn btn-active btn-primary w-full" on:click disabled={loading}
|
||||||
>Send magic link</button
|
>Send magic link</button
|
||||||
>
|
>
|
||||||
|
|
||||||
{#if message}
|
|
||||||
<div class="text-success">
|
|
||||||
{message}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if error}
|
|
||||||
<div class="text-error">
|
|
||||||
{error}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user