Address Utilities - Admin Components
The @medusajs/dashboard/lib subpath exports the utilities that the Medusa Admin uses to display and compare addresses. Use them in your admin extensions to show an order's or customer's address the same way the Medusa Admin does.
getFormattedAddress#
Returns an address as an array of lines, ordered the way the Medusa Admin displays them: the full name, the company, the two address lines, a combined city, province, and postal code line, and the country's display name. Render each item of the array on its own line.
Parameters#
Returns#
Returns a of the address's lines. The array is empty when you don't pass an address.
country object, the utility resolves the country's display name from the country_code. If the code isn't a supported country, it falls back to the uppercase code.getFormattedCountry#
Returns a country's display name from its ISO 2 code.
Parameters#
Returns#
Returns a string of the country's display name. It returns the passed code when the country isn't supported, and an empty string when you don't pass a code.
isSameAddress#
Returns whether two addresses hold the same values. It compares the first name, last name, both address lines, city, postal code, province, and country code. It ignores the company and phone.
Parameters#
Returns
Returns a boolean that is true when the compared fields match. It returns false when either address is missing.