Skip to content

Commit efe547a

Browse files
committed
feat(ai): improve login ux
1 parent 466c4c9 commit efe547a

1 file changed

Lines changed: 43 additions & 41 deletions

File tree

‎src/lib/components/login.svelte‎

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Button from './ui/button/button.svelte';
66
import { authClient } from '$lib/auth-client';
77
import { useAuth } from '@mmailaender/convex-better-auth-svelte/svelte';
8-
import { ArrowRight, ArrowRightIcon } from '@lucide/svelte';
8+
import { ArrowRight, ArrowRightIcon, LoaderCircle } from '@lucide/svelte';
99
import { toast } from 'svelte-sonner';
1010
import Label from './ui/label/label.svelte';
1111
import * as InputGroup from '$lib/components/ui/input-group/index.js';
@@ -47,49 +47,51 @@
4747
<Card.Title>Log in as an organizer</Card.Title>
4848
</Card.Header>
4949
<Card.Content class="space-y-8">
50-
<Button
51-
disabled={loading}
52-
onclick={async () => {
53-
loading = true;
54-
toast.promise(
55-
authClient.signIn
56-
.oauth2({
50+
{#if loading}
51+
<div class="flex min-h-32 flex-col items-center justify-center gap-3">
52+
<LoaderCircle class="size-5 animate-spin" />
53+
</div>
54+
{:else}
55+
<Button
56+
disabled={loading}
57+
onclick={async () => {
58+
loading = true;
59+
try {
60+
const { error } = await authClient.signIn.oauth2({
5761
providerId: 'hca',
5862
callbackURL: '/organizer'
59-
})
60-
.then(({ data, error }) => {
61-
if (error) {
62-
loading = false;
63-
throw error;
64-
}
65-
return data;
66-
}),
67-
{
68-
loading: 'Loading...',
69-
success: 'Redirecting...',
70-
error: 'Something went wrong'
63+
});
64+
if (error) {
65+
loading = false;
66+
toast.error('Something went wrong');
67+
}
68+
} catch {
69+
loading = false;
70+
toast.error('Something went wrong');
7171
}
72-
);
73-
}}>Continue with Hack Club</Button
74-
>
75-
<form class="flex w-full flex-col gap-2">
76-
<Label for="email-{id}">Email</Label>
77-
<InputGroup.Root class="w-full">
78-
<InputGroup.Input
79-
type="email"
80-
name="email"
81-
id="email-{id}"
82-
required
83-
placeholder="iwill@hackthisclub.com"
84-
/>
85-
<InputGroup.Addon align="inline-end">
86-
<InputGroup.Button variant="default" type="submit">
87-
<ArrowRightIcon />
88-
Send Code
89-
</InputGroup.Button>
90-
</InputGroup.Addon>
91-
</InputGroup.Root>
92-
</form>
72+
}}
73+
>
74+
Continue with Hack Club
75+
</Button>
76+
<form class="flex w-full flex-col gap-2">
77+
<Label for="email-{id}">Email</Label>
78+
<InputGroup.Root class="w-full">
79+
<InputGroup.Input
80+
type="email"
81+
name="email"
82+
id="email-{id}"
83+
required
84+
placeholder="iwill@hackthisclub.com"
85+
/>
86+
<InputGroup.Addon align="inline-end">
87+
<InputGroup.Button variant="default" type="submit">
88+
<ArrowRightIcon />
89+
Send Code
90+
</InputGroup.Button>
91+
</InputGroup.Addon>
92+
</InputGroup.Root>
93+
</form>
94+
{/if}
9395
</Card.Content>
9496
{/if}
9597
</Card.Root>

0 commit comments

Comments
 (0)