diff --git a/packages/admin-next/dashboard/src/components/inputs/country-select/country-select.tsx b/packages/admin-next/dashboard/src/components/inputs/country-select/country-select.tsx index c51b59e934..29bd4ec0ee 100644 --- a/packages/admin-next/dashboard/src/components/inputs/country-select/country-select.tsx +++ b/packages/admin-next/dashboard/src/components/inputs/country-select/country-select.tsx @@ -12,56 +12,67 @@ import { countries } from "../../../lib/data/countries" export const CountrySelect = forwardRef< HTMLSelectElement, - ComponentPropsWithoutRef<"select"> & { placeholder?: string } ->(({ className, disabled, placeholder, ...props }, ref) => { - const { t } = useTranslation() - const innerRef = useRef(null) + ComponentPropsWithoutRef<"select"> & { + placeholder?: string + value?: string + defaultValue?: string + } +>( + ( + { className, disabled, placeholder, value, defaultValue, ...props }, + ref + ) => { + const { t } = useTranslation() + const innerRef = useRef(null) - useImperativeHandle(ref, () => innerRef.current as HTMLSelectElement) + useImperativeHandle(ref, () => innerRef.current as HTMLSelectElement) - const isPlaceholder = innerRef.current?.value === "" + const isPlaceholder = innerRef.current?.value === "" - return ( -
- - -
- ) -}) + return ( +
+ + +
+ ) + } +) CountrySelect.displayName = "CountrySelect" diff --git a/packages/admin-next/dashboard/src/lib/addresses.ts b/packages/admin-next/dashboard/src/lib/addresses.ts index 24b18bea98..c9177371c2 100644 --- a/packages/admin-next/dashboard/src/lib/addresses.ts +++ b/packages/admin-next/dashboard/src/lib/addresses.ts @@ -1,6 +1,6 @@ import { AddressDTO } from "@medusajs/types" -import { countries } from "./data/countries" +import { countries, getCountryByIso2 } from "./data/countries" export const isSameAddress = (a: AddressDTO | null, b: AddressDTO | null) => { if (!a || !b) { @@ -72,7 +72,13 @@ export const getFormattedAddress = ({ if (country) { formattedAddress.push(country.display_name) } else if (country_code) { - formattedAddress.push(country_code.toUpperCase()) + const country = getCountryByIso2(country_code) + + if (country) { + formattedAddress.push(country.display_name) + } else { + formattedAddress.push(country_code.toUpperCase()) + } } return formattedAddress