diff --git a/frontend/src/hooks/useAuth.ts b/frontend/src/hooks/useAuth.ts index 786c36c..58d8db7 100644 --- a/frontend/src/hooks/useAuth.ts +++ b/frontend/src/hooks/useAuth.ts @@ -58,6 +58,7 @@ const useAuth = () => { user, isLoading, error, + resetError: () => setError(null), } } diff --git a/frontend/src/routes/login.tsx b/frontend/src/routes/login.tsx index 5e575b9..55db35f 100644 --- a/frontend/src/routes/login.tsx +++ b/frontend/src/routes/login.tsx @@ -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 = async (data) => { - loginMutation.mutate(data) + if (isSubmitting) return + + resetError() + + try { + await loginMutation.mutateAsync(data) + } catch { + // error is handled by useAuth hook + } } return (