Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[change] Create reusable function for errors #357

Closed
nemesifier opened this issue Aug 22, 2021 · 5 comments · Fixed by #361
Closed

[change] Create reusable function for errors #357

nemesifier opened this issue Aug 22, 2021 · 5 comments · Fixed by #361
Labels
enhancement New feature or request

Comments

@nemesifier
Copy link
Member

Right now we are including a lot of code like:

{errors.username && (
  <div className="error">
    <span className="icon">!</span>
    <span className="text">{errors.username}</span>
  </div>
)}

Maybe we can create an utility function (not sure if it's worth it to have another component for this as it will complicate the tree a lot) for this? This would give us the following advantages:

  • bring down size a bit (these lines are repated in almost all components)
  • make it easy to change the style of errors

I am thinking of something like:

fieldError (errors, key) => {
  (
    {errors[key] ? (
      <div className="error">
        <span className="icon">!</span>
        <span className="text">{errors[key]}</span>
      </div>
    ) : ''}
  );
}
@totallynotvaishnav
Copy link
Member

Can I work on this?

@nemesifier
Copy link
Member Author

Can I work on this?

Sure, go ahead 👍

@codesankalp
Copy link
Member

codesankalp commented Aug 23, 2021

Hello @iamvaishnav, Can you proceed with some other issue (because this issue needs to be fixed asap)?
I would suggest going ahead with #358 or #314 issue.

@totallynotvaishnav
Copy link
Member

@codesankalp Yeah, sure.

codesankalp added a commit that referenced this issue Aug 24, 2021
Added get-error-field to remove repeated code.

Closes #357
codesankalp added a commit that referenced this issue Aug 24, 2021
Added get-error-field to remove repeated code.

Closes #357
@nemesifier
Copy link
Member Author

@iamvaishnav take a look at #362, maybe it's something that interests you? Come to the OpenWISP support chat if you have any question or to better coordinate with us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants