-
Notifications
You must be signed in to change notification settings - Fork 54
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
Elisa/5818 facility form #5983
Elisa/5818 facility form #5983
Conversation
56f33d6
to
209d3e8
Compare
899a5af
to
0875d86
Compare
const { orderingProvider: provider } = facility; | ||
const isRequired = requiresOrderProvider(facility.state || ""); | ||
const isValidNPI = (npi: string) => { | ||
return /^\d{10}$/.test(npi); |
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.
/^\d{1,10}$/
, which means the NPI could be set to anything with less than 10 digits which according to our error message is incorrect.
Let me know if I should change this back to the previous regex.
0cf185a
to
4740da9
Compare
4740da9
to
14e7cee
Compare
14e7cee
to
6a763fd
Compare
6a763fd
to
68d7196
Compare
68d7196
to
e82824d
Compare
e82824d
to
876fe4b
Compare
const zipCodeData = await getZipCodeData(originalFacilityAddress.zipCode); | ||
const isValidZipForState = isValidZipCodeForState( | ||
originalFacilityAddress.state, | ||
zipCodeData | ||
); | ||
|
||
if (!isValidZipForState) { | ||
showError("Invalid ZIP code for this state", "Form Errors"); | ||
setError("facility.zipCode", { |
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.
we are not checking if the ordering provider's zip code and state (if provided, since it is not required) are valid combinations -- this is the current behavior as well
registrationProps={register("orderingProvider.zipCode", { | ||
required: false, | ||
validate: { | ||
validZip: (zipCode: string) => |
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.
validationStatus={errors?.facility?.email?.type ? "error" : undefined} | ||
errorMessage={errors?.facility?.email?.message} | ||
registrationProps={register("facility.email", { | ||
required: false, |
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.
nit: I believe required is defaulted to false so we don't need to specify this field,
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.
ooo thank you!
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.
Great job on the migration! I tested the form and it works smoothly. I left some questions but overall this looks awesome. Thanks for the work!
clearErrors, | ||
formState: { errors, isSubmitting, isDirty }, | ||
} = useForm({ | ||
mode: "onBlur", |
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.
Can the validation be set on submit?. I have found that the validation on blur is disruptive when using screen readers plus it will be more performant. LMK!
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.
ooo ok! Yes, I will remove this line as I think the default onsubmit! Thank you!
</span> | ||
) | ||
} | ||
onChange={() => {}} |
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.
Can the onChange prop in the Dropdown component be set as optional so we don't have to set dummy handlers?
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.
oooo good call!
onChange={(newDeviceIds) => { | ||
updateDevices(newDeviceIds); | ||
}} | ||
onChange={onChange} |
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.
Is this onChange being triggered or is react-hook-forms overriding it? If it is the later I would suggest removing the onChange prop from this component and making the onChange prop in the multi select optional so we can clean up the code that is not really being used.
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.
Yes! This onChange is being triggered to update the selected devices and display an error if the device list is empty. Based on that, let me know if you see room for improvement! Thank you!!
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.
👍
@fzhao99 @BobanL @johanna-skylight -- so sorry everyone who reviewed! found one last bug where the suggested address wasn't showing up when provided with a ordering provider address -- added a test for this. Ready for (hopefully - final 🤞 😅) review!! |
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.
thank you for breaking out the strings!
Kudos, SonarCloud Quality Gate passed! |
FRONTEND PULL REQUEST
Related Issue
Resolves #5818
Changes Proposed
react-hook-form
libraryFacilitySchema.ts
Additional Information
Testing
Screenshots / Demos