From 3558cb300d1f6e9fd1e832cedd6a1b268a585d7f Mon Sep 17 00:00:00 2001 From: vrthelen Date: Mon, 18 Mar 2024 17:48:35 -0400 Subject: [PATCH] prior commit with strange error handling --- src/pages/Register/index.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pages/Register/index.tsx b/src/pages/Register/index.tsx index d5f3785..66212dc 100644 --- a/src/pages/Register/index.tsx +++ b/src/pages/Register/index.tsx @@ -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) => { - registerUser() e.preventDefault() + registerUser() } return (