Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
some error handling added
Browse files Browse the repository at this point in the history
  • Loading branch information
vrthelen committed Mar 18, 2024
1 parent 3257198 commit 927080e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pages/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,20 @@ const RegistrationForm = () => {
navigate('/register/confirm')
},
onError: err => {
// TODO: if status is 409, tell user that email/username is already registered
// FIX: error.message does not work?
setError(err.message || 'Registration failed. Please try again.')
if (err.status === 409) {

Check failure on line 110 in src/pages/Register/index.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'status' does not exist on type 'Error'.
setError('This email or username is already registered.')
} else if (err.status === 400) {

Check failure on line 112 in src/pages/Register/index.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'status' does not exist on type 'Error'.
setError('Invalid input. Please try again.')
} else {
setError('Registration failed. Please try again.')
}
}
}
)

const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
registerUser()
e.preventDefault()
registerUser()
}

return (
Expand Down

0 comments on commit 927080e

Please sign in to comment.