refactor(SW-360): improve error handling logic
This commit is contained in:
@@ -52,17 +52,11 @@ export default function Form({ link, subtitle, title }: RegisterFormProps) {
|
||||
const zipCode = intl.formatMessage({ id: "Zip code" })
|
||||
|
||||
async function handleSubmit(data: RegisterSchema) {
|
||||
const isSuccessResponse = await registerUser(data)
|
||||
if (!isSuccessResponse) {
|
||||
toast.error("Something went wrong!")
|
||||
} else {
|
||||
// TODO: Toast should be removed and we should show a different page
|
||||
toast.success("Form submitted successfully")
|
||||
// should we navigate to sub route like /signup/success ?
|
||||
// router.push("/")
|
||||
|
||||
methods.reset()
|
||||
const result = await registerUser(data)
|
||||
if (!result.success) {
|
||||
toast.error(intl.formatMessage({ id: "Something went wrong!" }))
|
||||
}
|
||||
// No need to handle success case here, as the redirect happens server-side.
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user