cds-snc / platform-forms-client

NextJS application that serves the public-facing website for Forms
https://forms-staging.cdssandbox.xyz/
MIT License
34 stars 13 forks source link

AddressComplete component #3564

Open Abi-Nada opened 5 months ago

Abi-Nada commented 5 months ago

User story

As a form builder / program administrator, I want to get complete and accurate addresses, So that what I collect is legitimate and what I send as correspondence gets to the right destination.

As a form filler / member of the public, I want my address to be filled in the right format, So that I can fill out the form and get access to programs and services more easily, quickly, predictably, and efficiently.

Context

AddressComplete is an address finder component developed by Canada Post, that includes real-time verification of addresses. This helps ensure the accuracy of data submitted in a form and helps people filling out a form save time.

AddressComplete takes a master international data set and supplements it with address data from some of the world’s major postal service providers to fully validate data.

This component enables a rapid searching functionality that works as you type. It includes validation for 240 countries using the official federal registry. Custom addresses can still be added if the address is not found while filling out the form.

There is a cost per API call based on a set limit of credits. As such, we will group all the fields as one block or entity to make one call per submission rather than multiple for each field.

As part of the integration and implementation we will re-use the combo-box to have the component function similarly to our type-ahead searchable list.

There is a "find" API and a "retrieve" API. Need to sort out what the costing model is and if billing for lookup calls (10c?) is only for calls to the retrieve or also the find API? How will it work with credit balances and top ups?

Links

What's involved

samsadasivan commented 4 months ago

Started here!

anikbrazeau commented 4 months ago

https://docs.google.com/document/d/1ugZCOjXXLwH6Jt2zP2m8_9fzrohdvnB1ATscGznZ6C0/edit#heading=h.218poww6tt5w

samsadasivan commented 4 months ago

Finished up discovery/exploration work! > On to proposal mock ups > putting together a report for findings

anikbrazeau commented 2 months ago

Notes from meeting with Sam

https://www.figma.com/design/5PqqBQR0s0Q8wkvB75pq2C/Address-complete?node-id=1-36&m=dev

anikbrazeau commented 1 month ago

Latest explorations: https://www.figma.com/design/5PqqBQR0s0Q8wkvB75pq2C/Address-complete?node-id=4353-6756&t=WMNIKwpE9X5mfoal-4

Screenshot 2024-08-08 at 4.50.58 PM.png
anikbrazeau commented 1 month ago

Takeaways from meeting with @hegazynourhan :

Also found these relevant policy docs:

anikbrazeau commented 1 month ago

Latest mock-up: https://www.figma.com/design/5PqqBQR0s0Q8wkvB75pq2C/Address-complete?node-id=4444-1575&t=JZwaQ3lF3U2wnx2p-4

Screenshot 2024-08-16 at 3 38 11 PM

anikbrazeau commented 1 month ago

I reached out to Canada Post and learned:

anikbrazeau commented 1 month ago

Latest design wireframes: https://www.figma.com/design/5PqqBQR0s0Q8wkvB75pq2C/Address-complete?node-id=4458-2427&t=szxmGV34mZlke074-4

Simplifying the address data:

"Id", "StreetAddress" {"StreetNumber",
"StreetName",
"StreetType", "StreetNumberSuffix",} "City", "ProvinceName" {"ProvinceCode",} "CountryName", {"CountryCode",} "PostalCode" "Zip", {"PostalCodePrefix", "PostalCodeSuffix",}


srtalbot commented 1 month ago

Basic implementation that works. Moving on to:

anikbrazeau commented 1 month ago

Notes from risk discussion:

https://docs.google.com/document/d/1JmWpX6RaSTnl1uY-e0X4je2XPrJKeucQm8w_tBLI7TM/edit

Learnings from contacting Canada Post:

srtalbot commented 1 month ago

Staging env has a trial API key (for 2 more months) for AddressComplete. It pulls the information when users select fields.

Working on the review page, response and downloads, and caching.

ShadeWyrm commented 1 month ago

Todo: -> Bug fix for clicking Split vs Full Address needing to be selected twice. -> Response and Download Page -> Caching -> Implement "Partial Address Lookup" API call. (Ocassionally the API will return a "Send this w/ Key" to pull more results. Like Pagination but different. -> Disable Option for AdressComplete (total) and per Form

Abi-Nada commented 2 weeks ago

To do: -> Implement "Partial Address Lookup" API call. (Ocassionally the API will return a "Send this w/ Key" to pull more results. Like Pagination but different. -> Figuring out what dollar amount we want to limit to per day -> Testing

Abi-Nada commented 2 weeks ago

@anikbrazeau and @ShadeWyrm to connect on UX issue

Abi-Nada commented 2 weeks ago

Flag to @srtalbot for QA testing once this is resolved ^

Abi-Nada commented 2 weeks ago

To Do:

anikbrazeau commented 2 weeks ago

QA Testing link: https://whs5lohqxjml4lvkpfz2enucau0tzxym.lambda-url.ca-central-1.on.aws/

anikbrazeau commented 2 weeks ago

For a future iteration:

srtalbot commented 2 weeks ago

QA Testing

OS & Browser Mac Chrome

  1. Are we able to update the component preview to show a the single address complete field, rather than multiple address fields?

    image.png
  2. An addresses that is selected still shows the auto-complete entry. It is only removed on another click away.

    image.png

Is that expected, or can we make it so that once it's selected (clicked) it just shows the entry.

  1. A split address that has a custom entered address provides and error.

Steps to recreate:

image.png
  1. Split address does not show up on the review page.

Steps to recreate:

image.png
  1. Test and live responses did not have the data input and submitted in CSV, JSON, or HTML formats.
image.png
  1. More of a question than a bug - where is the option to shut off address complete for a single form?

  2. Tried to delete the form, but it gave me an error. (Form submissions have been downloaded and confirmed.) Also, clicking the "x" on the error notification would not close the toast message and it persisted when I navigated to other pages.

A refresh cleared the message and showed the form as deleted.

image.png
ShadeWyrm commented 2 weeks ago
  1. Yes we can, but did we want to have the default have all fields selected? What makes the most sense?
  2. Will fix.
  3. We may need to decide how a split address should work if an address isn't found. As is the component would only allow you to do so with all fields selected. I'm not sure how this should work UX wise.
  4. Unusual, I'll try and duplicate - responses should of come back correctly.
  5. Related to above.
  6. Not yet Implemented, as. it's not a function that exists in the application yet anywhere else and the PR is growing quite large.
  7. Interesting. Not sure what caused that. I'll investigate. 8.^
anikbrazeau commented 1 week ago

Note:

Next steps:

dsamojlenko commented 1 week ago

Re: discussion during standup about managed data components (ie, Departments) and the possibility of creating one for Countries.

Here is the directory where we provide the managed Departments list: https://github.com/cds-snc/platform-forms-client/tree/develop/lib/managedData

The intention was that the data directory could contain multiple managed raw data sources in JSON format, and the index file would serve as the gateway to them, calling back to a mapping file that is responsible for parsing the raw json and if necessary filtering and providing the data in a format that the Combobox can use.

The JSON can come from wherever- in the case of Departments we pulled it from a CDS repo on github.

I misremembered during the meeting that I thought we had a mechanism to automatically update the Departments list from the source, but looks like we didn't get that far. That should be a consideration at some point as the source data can change over time.

This managed data is used along with a "Form Builder Template" to create the Departments component: https://github.com/cds-snc/platform-forms-client/blob/develop/form-builder-templates/departments.json

This was built as part of the Managed Data / Combobox features PR: https://github.com/cds-snc/platform-forms-client/pull/3139