Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from perxhealth/feature/PX-907
Browse files Browse the repository at this point in the history
Bump version number + fix conditional use of international number
  • Loading branch information
jmhar3 authored Sep 6, 2023
2 parents 3998c7b + e619f83 commit 4c4b977
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/forms/PhoneInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("PhoneInput", () => {
const { getByRole, getByLabelText, user } = setup()
await user.selectOptions(getByLabelText("Select a country"), "AU")
await user.type(getByRole("textbox"), "491570156")
expect(parsePhoneNumber).toHaveBeenCalledWith("+614", "AU")
expect(parsePhoneNumber).toHaveBeenCalledWith("4", "AU")
expect(onChange).toHaveBeenCalledWith("+61491570156")
})
})
Expand All @@ -159,7 +159,7 @@ describe("PhoneInput", () => {
const { getByRole, getByLabelText, user } = setup()
await user.selectOptions(getByLabelText("Select a country"), "US")
await user.type(getByRole("textbox"), "491570156")
expect(parsePhoneNumber).toHaveBeenCalledWith("+14", "US")
expect(parsePhoneNumber).toHaveBeenCalledWith("4", "US")
expect(onChange).toHaveBeenCalledWith("+1491570156")
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/PhoneInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ export const PhoneInput = (props: PhoneInputProps) => {

// Format the number as E164 and send it along
const parsedPhoneNumber = parsePhoneNumber(
`${isInternational && currentCountry.callingCode}${value}`,
value,
currentCountry.countryCode as LibCountryCode
)

if (onChange) {
onChange(parsedPhoneNumber.number)
onChange(isInternational ? parsedPhoneNumber.number : value)
}

if (onValidatePhoneNumber) {
Expand Down

0 comments on commit 4c4b977

Please sign in to comment.