-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 1594 - Enhance Phone Number Input Handling with State Management and Validation #1720
base: develop
Are you sure you want to change the base?
Conversation
@@ -614,7 +644,7 @@ function CreatePatientForm(props) { | |||
<Field name="primaryPhone"> | |||
{({ field }) => ( | |||
<TextInput | |||
value={values.primaryPhone || ""} | |||
value={phoneNumber} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesnt set a phone values for an existing patient
const phoneRegex = new RegExp(escapedPhoneFormat); | ||
|
||
if (!phoneRegex.test(value)) { | ||
console.warn("Invalid phone number format"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a visible message on the UI not just in the console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does alert works?
|
||
setPhoneNumber(value); | ||
|
||
if (configurationProperties.PHONE_FORMAT && value.length > 10) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would you hard code a specific lenght
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the length check was initially added to prevent premature validation while the user was still typing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the old UI and found the Ajax call for phone number validation, but I couldn't get it to work in the latest version. It seems like the Ajax validation might not be in use anymore. For now, I have ensured that only numeric input is allowed in the phone field. Let me know if there's a specific API or validation method I should use instead!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mozzy11 I noticed that the phone number validation API returns true only when the phone number is encoded (e.g., %2B225-12-23-56-23) but returns false for the same number when sent as +225-12-23-56-23 or without + as well
here's the controller CommonValidationsRestController.java
.
.
For handling this on the frontend, should I:
- Call the API on form submission and show a notification if the phone number is invalid?
- Validate using regex on the frontend only and display an error message directly below the phone number field?
@mozzy11, I've implemented changes so that on form submission, the API will validate the phone number. The backend service expects the + to be URL-encoded and the number to follow the format 225-xx-xx-xx-xx, as mentioned in my previous response. Here are some screenshots for reference: let me know if you're good with these changes, or I can roll back to the previous implementation, which only accepted numeric input. Thanks! |
Pull Requests Requirements
Issue number if applicable.
documentation.
Summary
This PR improves the phone number input handling by:
Related Issue
#1594