Skip to content

Conversation

@dr-bizz
Copy link
Contributor

@dr-bizz dr-bizz commented Jan 27, 2025

Description

In this PR, I changed how we format the subpremise (Apt, Unit or Suite number) on an address.
Before, we always put it in front of the street address formatted like Apt 100/Street Address. This is the correct format for the UK, CA and many other countries, but the US and Singapore prefer that subpremise be used at the end of the address.

USPS stated the subpremise should be after the street address
Singapore stated the subpresmise should be after the address prefixed with a hashtag.

Helpscout
Jira: MPDX-8521

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@dr-bizz dr-bizz added the Preview Environment Add this label to create an Amplify Preview label Jan 27, 2025
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

Bundle sizes [mpdx-react]

Compared against 56b3a38

No significant changes found

@wrandall22
Copy link
Contributor

I wonder if we shouldn't be using a library to handle this for us, like localized-address-format.

@dr-bizz
Copy link
Contributor Author

dr-bizz commented Jan 27, 2025

I looked into a formatter. I didn't find one that does what we need it to.

I installed and tested the following NPM packages.

  1. localized-address-format
  2. @fragaria/address-formatter
  3. i18n-postal-address
    Unfortunately, none of these took a subpremise as a parameter when formatting the address. I played around with adding the subpremise to the start and end of the street name, but it doesn't format it correctly.

@dr-bizz
Copy link
Contributor Author

dr-bizz commented Jan 27, 2025

Today, I met with Scott and the other developers, and we believe we can use the Google Places API for this task. However, it will require significant effort and has been scheduled for T2.

In the meantime, I have manually added the formatting for the US, Singapore, and most countries, including the UK and Canada. However, this will be replaced in the near future so we can manage this more efficiently.

@dr-bizz dr-bizz requested a review from canac January 27, 2025 20:14
Copy link
Contributor

@canac canac left a comment

Choose a reason for hiding this comment

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

This looks like it handles addresses for those countries well. I tested with the address "4200 Eldorado Pkwy STE 200, McKinney, TX 75070" and correctly it put the suite after the street number/name.

… Changing tests to the new formatted address
@dr-bizz dr-bizz force-pushed the US-and-Singapore-address-formatting branch from 0d02778 to 1ee0fee Compare January 27, 2025 21:06
@dr-bizz dr-bizz enabled auto-merge January 27, 2025 21:06
@dr-bizz dr-bizz merged commit 022a187 into main Jan 27, 2025
18 checks passed
@dr-bizz dr-bizz deleted the US-and-Singapore-address-formatting branch January 27, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants