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

feat(v2): add handling of prefill for authed public forms, show fields correctly when logged in #4275

Merged
merged 8 commits into from
Jul 25, 2022

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Jul 22, 2022

Problem

This PR implements prefill for authenticatable public forms following AngularJS implementation in #3920.
Also contains a bug fix where form fields are still not shown when user is logged in.

Closes #3630

Solution

Breaking Changes

  • No - this PR is backwards compatible

Features:

  • add hooks to store and retrieve prefill query strings when user is logging into a form
    • feat: add useStorePrefillQuery and useFetchPrefillQuery hooks
  • feat: reset default form values to new values if changed (allows for query to get updated when search params get set programatically)
  • add useSessionStorage hook for session storage manipulation

Bug Fixes:

  • fix: correctly show public auth only if spcpSession is not defined

@karrui karrui requested review from mantariksh and timotheeg July 22, 2022 07:47
PublicFormProvider now uses useSearchParams hook, which requires memory router
Copy link
Contributor

@timotheeg timotheeg left a comment

Choose a reason for hiding this comment

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

lgtm (?) . I have 2 minor comments

// Do nothing if key is already query key. Might result in infinite loop if handled.
if (searchParams.get(REDIRECTED_QUERY_KEY)) return

const queryParams = Object.fromEntries([...searchParams])
Copy link
Contributor

Choose a reason for hiding this comment

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

/superNit

Suggested change
const queryParams = Object.fromEntries([...searchParams])
const queryParams = Object.fromEntries(searchParams.entries())

@karrui karrui merged commit 32a25cc into form-v2/develop Jul 25, 2022
@karrui karrui deleted the form-v2/prefill-authed-public-form branch July 25, 2022 05:34
@justynoh justynoh mentioned this pull request Oct 5, 2022
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.

2 participants