|
9 | 9 | import { Button } from '$lib/components/ui/button'; |
10 | 10 | import * as Card from '$lib/components/ui/card'; |
11 | 11 | import * as Dialog from '$lib/components/ui/dialog'; |
| 12 | + import { handleApiError } from '$lib/errorhandling/apiErrorHandling'; |
12 | 13 | import { validatePasswordMatch } from '$lib/inputvalidation/passwordValidator'; |
13 | 14 | import { toast } from 'svelte-sonner'; |
14 | 15 |
|
|
56 | 57 | turnstileResponse, |
57 | 58 | }) |
58 | 59 | .then(() => (accountCreated = true)) |
| 60 | + .catch(handleApiError) |
59 | 61 | .finally(() => { |
60 | 62 | turnstileResponse = null; |
61 | 63 | }); |
|
75 | 77 | </Dialog.Content> |
76 | 78 | </Dialog.Root> |
77 | 79 |
|
78 | | -<Container> |
79 | | - <Card.Header> |
80 | | - <Card.Title class="text-3xl text-nowrap">Sign Up</Card.Title> |
81 | | - </Card.Header> |
82 | | - <Card.Content> |
83 | | - <form class="flex flex-col space-y-2" onsubmit={handleSubmission}> |
84 | | - <UsernameInput |
85 | | - label="Username" |
86 | | - placeholder="Username" |
87 | | - bind:value={username} |
88 | | - bind:valid={usernameValid} |
89 | | - /> |
90 | | - <EmailInput label="Email" placeholder="Email" bind:value={email} bind:valid={emailValid} /> |
91 | | - <PasswordInput |
92 | | - label="Password" |
93 | | - placeholder="Password" |
94 | | - autocomplete="new-password" |
95 | | - bind:value={password} |
96 | | - bind:valid={passwordValid} |
97 | | - validate={true} |
98 | | - showStrengthMeter={true} |
99 | | - /> |
100 | | - <PasswordInput |
101 | | - label="Confirm Password" |
102 | | - placeholder="Confirm Password" |
103 | | - autocomplete="new-password" |
104 | | - bind:value={passwordConfirm} |
105 | | - validate={validatePasswordMatch(passwordConfirm, password)} |
106 | | - /> |
107 | | - |
108 | | - <Turnstile action="signup" bind:response={turnstileResponse} /> |
109 | | - |
110 | | - <Button type="submit" disabled={!canSubmit}>Sign Up</Button> |
111 | | - </form> |
112 | | - </Card.Content> |
| 80 | +<Container class="items-center"> |
| 81 | + <form class="flex flex-col gap-2" onsubmit={handleSubmission}> |
| 82 | + <div class="text-3xl font-semibold text-nowrap">Sign Up</div> |
| 83 | + <UsernameInput |
| 84 | + label="Username" |
| 85 | + placeholder="Username" |
| 86 | + bind:value={username} |
| 87 | + bind:valid={usernameValid} |
| 88 | + /> |
| 89 | + <EmailInput label="Email" placeholder="Email" bind:value={email} bind:valid={emailValid} /> |
| 90 | + <PasswordInput |
| 91 | + label="Password" |
| 92 | + placeholder="Password" |
| 93 | + autocomplete="new-password" |
| 94 | + bind:value={password} |
| 95 | + bind:valid={passwordValid} |
| 96 | + validate={true} |
| 97 | + showStrengthMeter={true} |
| 98 | + /> |
| 99 | + <PasswordInput |
| 100 | + label="Confirm Password" |
| 101 | + placeholder="Confirm Password" |
| 102 | + autocomplete="new-password" |
| 103 | + bind:value={passwordConfirm} |
| 104 | + validate={validatePasswordMatch(passwordConfirm, password)} |
| 105 | + /> |
| 106 | + |
| 107 | + <Turnstile action="signup" bind:response={turnstileResponse} /> |
| 108 | + |
| 109 | + <Button type="submit" disabled={!canSubmit}>Sign Up</Button> |
| 110 | + </form> |
113 | 111 | </Container> |
0 commit comments