zeeguu / web

Frontend for the zeeguu web application.
https://www.zeeguu.org
3 stars 5 forks source link

Auth and preference pages #346

Closed igawaclawska closed 2 months ago

igawaclawska commented 2 months ago

Overall changes:

Log in page
Current: desktop mobile
www zeeguu org_login (4) www zeeguu org_(iPhone 12 Pro)
This PR: desktop mobile
localhost_3000_login localhost_3000_login(iPhone 12 Pro)
Create account page
Current: desktop mobile
www zeeguu org_create_account (1) www zeeguu org_create_account(iPhone 12 Pro) (1)
This PR: desktop mobile
localhost_3000_create_account localhost_3000_create_account(iPhone 12 Pro)
Reset password page
Current: desktop mobile
www zeeguu org_reset_pass www zeeguu org_reset_pass(iPhone 12 Pro)
This PR: desktop mobile
localhost_3000_reset_pass localhost_3000_reset_pass(iPhone 12 Pro)
Language preferences settings
desktop mobile
localhost_3000_language_preferences localhost_3000_language_preferences(iPhone 12 Pro)

Language preferences settings are separated from the registration page and have their own page and endpoint: language_preferences

      <PrivateRoute
        path="/language_preferences"
        api={api}
        setUser={setUser}
        component={LanguagePreferences}
      />

Input

As we discussed and agreed on Monday, the 15th, I kept the validation logic unchanged for now. It's still a global message displayed on the form field, but it has now been redesigned to be visually distinct from the input fields.  

Validation
Current
www zeeguu org_login (3)
This PR
localhost_3000_login (2)

If we want in the future to implement a real-time validation that supports error messages displayed directly below input fields - the new custom input field component will allow us to do so now (similarly to how it can be achieved using mui input fields).

Input other states
Active active
Error (we will be able to use this state after adapting the way we validate inputs) Screenshot 2024-04-26 at 19 31 11

The useFormField custom hook controls the behavior of the new form fields. For now, it handles basic state updates, but it can be expanded to handle individual error messages per input field, etc.

The hook:

/* 
A custom hook controlling form field logic.
It could be extended with:
    - validation support (a function with validation rules could be passed as an argument)
    - error message states 
*/

export default function useFormField(initialState) {
  const [currentState, setState] = useState(initialState);

  function handleInputChange(e) {
    setState(e.target.value);
  }

  function resetInputState() {
    setState("");
  }

  return [currentState, handleInputChange, resetInputState];
}

Usage example in CreateAccount.js:

  const [inviteCode, handleInviteCodeChange] = useFormField("");
  const [name, handleNameChange] = useFormField("");
  const [email, handleEmailChange] = useFormField("");
  const [password, handlePasswordChange] = useFormField("");

Privacy Notice

The Privacy Notice text has now been removed from the Registration page and is available as a link.

For now, the validation does not consider the Privacy notice checkbox, as I left it open for discussion. Let's discuss our approach on Monday.


Buttons:

button-gif

netlify[bot] commented 2 months ago

Deploy Preview for voluble-nougat-015dd1 ready!

Name Link
Latest commit f229b9ff47f331c920961042e84ac12768a7fbf7
Latest deploy log https://app.netlify.com/sites/voluble-nougat-015dd1/deploys/663914b40a719000087a6422
Deploy Preview https://deploy-preview-346--voluble-nougat-015dd1.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

igawaclawska commented 2 months ago

Hi @mircealungu and @tfnribeiro

The changes that we discussed last Monday are now addressed:

Additionally, I have adapted this PR to the newest updates on main so that it no longer has merge conflicts.


Also, This PR mainly introduces changes to the following pages: Log-in, Registration, Password Reset, and Language Selection. However, I have also worked on the Keywords Exclusion pages (from another branch that is dependent on this one because I needed components introduced here). Should I incorporate these changes into this PR or make a separate one after this one is approved/merged?