Patrick Arminio
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
11 additions and
2 deletions
-
frontend/src/hooks/useAuth.ts
-
frontend/src/routes/login.tsx
|
|
@ -58,6 +58,7 @@ const useAuth = () => { |
|
|
|
user, |
|
|
|
isLoading, |
|
|
|
error, |
|
|
|
resetError: () => setError(null), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -38,7 +38,7 @@ export const Route = createFileRoute("/login")({ |
|
|
|
|
|
|
|
function Login() { |
|
|
|
const [show, setShow] = useBoolean() |
|
|
|
const { loginMutation, error } = useAuth() |
|
|
|
const { loginMutation, error, resetError } = useAuth() |
|
|
|
const { |
|
|
|
register, |
|
|
|
handleSubmit, |
|
|
@ -53,7 +53,15 @@ function Login() { |
|
|
|
}) |
|
|
|
|
|
|
|
const onSubmit: SubmitHandler<AccessToken> = async (data) => { |
|
|
|
loginMutation.mutate(data) |
|
|
|
if (isSubmitting) return |
|
|
|
|
|
|
|
resetError() |
|
|
|
|
|
|
|
try { |
|
|
|
await loginMutation.mutateAsync(data) |
|
|
|
} catch { |
|
|
|
// error is handled by useAuth hook
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return ( |
|
|
|