Skip to content

Disable register and login forms while submitting (waiting for async fetch) #17

@AtikoSpeed

Description

@AtikoSpeed

When onRegister() (in /register) or onLogin() (in /login) is called, it will take some time for the async request to be processed. The textboxes and submit button should be disabled during this time to prevent multiple identical requests being made while the previous ones are processing.
In case there is an error, an error message should be displayed and the text fields re-enabled for the user to correct their mistake.

FİLES TOUCHED
src/login/index.js
src/register/index.js
src/context/auth.js (possibly)

WHAT DO THEY RETURN?
onLogin and onRegister are async at their base but one might need to add async on the login and register pages depending on the behavior

They do not return any message, only save a JWT and user info into the local storage. They should be made to return success on success or in case of an error, error and an error message to be dispayed on the login/register page.

The response format should be:

{
status: success,
}

or

{
status: error,
errormessage: "one of the errors below",
}

Success does not have to return a message because the user will be taken to another page on success.

Error messages:
onRegister

if email exists
errormessage: “Email is already in use”

onLogin

if email & password combination has no match
errormessage: “Incorrect email or password”

SPİNNER
There does not seem to be a spinner included in the codebase. There is a library called react-spinners that one could use. It includes different styles of spinners. We are going to install it through npm.

The spinner will go on the left of the disabled button.

İMPLEMENTATİON
auth.js should be altered to return an error message in case of an error
TextInput and Button components in both login, and register pages should have a disabled=true prop after the submit button is clicked. They should be re-enabled in case of an error returned by changing the prop to disabled=false. They don’t have to be re-enabled in case the login/register is a success because the user will be taken to the next page anyway.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions