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

Display validation errors on NewPassword page #471

Merged
merged 4 commits into from
Apr 7, 2020
Merged

Display validation errors on NewPassword page #471

merged 4 commits into from
Apr 7, 2020

Conversation

gabmartinez
Copy link
Contributor

@gabmartinez gabmartinez commented Apr 7, 2020

I want to merge this change because it displays the validation errors on the New Password Page.

fix #468

Screenshots

Pull Request Checklist

  1. All visible strings are translated with proper context.
  2. All data-formatting is locale-aware (dates, numbers, and so on).
  3. Translated strings are extracted.
  4. Number of API calls is optimized.
  5. The changes are tested.
  6. Type definitions are up to date.
  7. Changes are mentioned in the changelog.

@codecov
Copy link

codecov bot commented Apr 7, 2020

Codecov Report

Merging #471 into master will increase coverage by 0.01%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #471      +/-   ##
==========================================
+ Coverage   72.33%   72.35%   +0.01%     
==========================================
  Files         658      658              
  Lines        7428     7436       +8     
  Branches     1225     1227       +2     
==========================================
+ Hits         5373     5380       +7     
- Misses       1818     1819       +1     
  Partials      237      237              
Impacted Files Coverage Δ
src/auth/views/NewPassword.tsx 14.28% <0.00%> (-1.10%) ⬇️
...onents/NewPasswordPage/NewPasswordPage.stories.tsx 83.33% <80.00%> (-16.67%) ⬇️
...uth/components/NewPasswordPage/NewPasswordPage.tsx 87.50% <100.00%> (+4.16%) ⬆️
src/utils/errors/account.ts 46.15% <0.00%> (+7.69%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55512b4...3ee7ce5. Read the comment docs.

Copy link
Contributor

@dominik-zeglen dominik-zeglen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except this little note above. Thanks for the contribution!

import { NewPasswordUrlQueryParams } from "../urls";

const NewPassword: React.FC<RouteComponentProps> = ({ location }) => {
const navigate = useNavigator();
const { loginByToken } = useUser();
const [errors, setErrors] = React.useState<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The state here is not needed. SetPasswordMutation returns setPasswordOpts, which has data property, allowing us to access data.setPassword.errors, which we can directly convey to NewPasswordPage as prop. I'll look like this

<NewPasswordPage
  errors={setPasswordOpts.data.?.setPassword.errors || []}
  ...
/>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. done.

Thank you ;)

@dominik-zeglen dominik-zeglen merged commit 0507811 into saleor:master Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Password validation errors are not shown
2 participants