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

Url Search Parameters #173

Merged
merged 5 commits into from
Dec 13, 2024
Merged

Url Search Parameters #173

merged 5 commits into from
Dec 13, 2024

Conversation

gabrielegranello
Copy link
Collaborator

What does this PR do?

It uses URL Search Parameters to partially fill the form. At the moment, it is set to work with the postcode.

How does it work?

It uses the React hook useSearchParams that reads the parameters passed in the URL. The default value of the postcode in the form is set to be equal to the passed parameter.

How to test it?

When the app is running on your localhost, for example localhost:3000, try to pass the postcode via the url.
For example, reload the page as localhost:3000/?postcode=SE171PE. You should find the postcode in the form to be equal to "SE171PE"

Copy link

vercel bot commented Dec 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fairhold-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 3:04pm

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

Perfect!

I think we might as well map all form fields here, which would allow Alastair to have the choice of which fields of the form to map in WebFlow 👍

@gabrielegranello
Copy link
Collaborator Author

Good point @DafyddLlyr . Now all the other parameters are available too. It can be tested with for example:
http://localhost:3000/?postcode=SE171PE&houseSize=80&houseAge=1&houseBedrooms=2&houseType=T&maintenancePercentage=0.02

@gabrielegranello gabrielegranello merged commit 89d4c1a into main Dec 13, 2024
5 checks passed
@DafyddLlyr DafyddLlyr deleted the gg/url-search-params branch December 13, 2024 15:15
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