Validate document capture step completion after page reload#3984
Merged
Validate document capture step completion after page reload#3984
Conversation
aduth
commented
Jul 28, 2020
| * @return {boolean} Whether step is valid. | ||
| */ | ||
| DocumentsStep.isValid = (value) => Boolean(value.front_image && value.back_image); | ||
| export const isValid = (value) => Boolean(value.front_image && value.back_image); |
Contributor
Author
There was a problem hiding this comment.
It's technically valid to assign a property into an instanceof Function, but the TypeScript JSDoc flavor doesn't handle this case very well to "re-open" the React component definition for extension. So I opted instead to make this a proper exported member of the module, which retains the benefit of colocality, while integrating a little better with type-checking.
aduth
commented
Jul 29, 2020
| * @return {number} Step index. | ||
| */ | ||
| export function getStepIndexByName(steps, name) { | ||
| return steps.findIndex((step) => step.name === name); |
Contributor
Author
There was a problem hiding this comment.
It occurs to me these methods may not be polyfilled correctly in Internet Explorer. I created a ticket LG-3241.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: The
useHistoryParamReact hook introduced in #3952 works a little too well in that it will blindly accept a hash parameter#step=selfieto skip to the corresponding step. This is not desirable in the case that the user reloads the page after completing one of the steps, since the state (form values) will not persist after the page reload. Instead, the step's validity logic (introduced in #3978) should be used to verify step completion of all form steps up until the one associated with value assigned to the URL hash. The user should be returned to the last step which qualifies as valid. In our case, this will be the first step (#step=documents).Screen recording: