UX Fix: clear all existing messages and errors

This commit is contained in:
Abdullah Mustapha 2023-12-29 14:16:06 +01:00
parent 33b15acbe9
commit 2fef6d7d45
8 changed files with 94 additions and 0 deletions

View file

@ -71,6 +71,8 @@ function SignUpClient(props: SignUpClientProps) {
},
validate,
onSubmit: async values => {
setError('')
setMessage('')
setIsSubmitting(true);
let res = await signup(values);
let message = await res.json();
@ -82,6 +84,7 @@ function SignUpClient(props: SignUpClientProps) {
else if (res.status == 401 || res.status == 400 || res.status == 404 || res.status == 409) {
setError(message.detail);
setIsSubmitting(false);
}
else {
setError("Something went wrong");