feat(#35): schedule toast rather than display text

This commit is contained in:
OllyNicholass
2024-11-19 19:23:17 +00:00
parent 7f9958cb24
commit 9c01db944b
+5 -19
View File
@@ -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>