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

Commit

Permalink
prior commit with strange error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vrthelen committed Mar 18, 2024
1 parent 3257198 commit 3558cb3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/pages/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,24 @@ 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.')
// eslint-disable-next-line
console.log(err)
if (err.status === 409) {
setError(
'This email or username is already registered. Please try again.'
)
} else if (err.status === 400) {
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 3558cb3

Please sign in to comment.