Skip to content
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

Merged
merged 13 commits into from
Jun 22, 2023
Merged

Elisa/5818 facility form #5983

merged 13 commits into from
Jun 22, 2023

Conversation

emyl3
Copy link
Collaborator

@emyl3 emyl3 commented Jun 14, 2023

FRONTEND PULL REQUEST

Related Issue

Resolves #5818

Changes Proposed

Additional Information

Testing

Screenshots / Demos

  • For large changes, please pair with a designer to ensure changes are as intended

@emyl3 emyl3 temporarily deployed to Dev5 June 14, 2023 16:56 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch from 56f33d6 to 209d3e8 Compare June 14, 2023 18:31
@emyl3 emyl3 temporarily deployed to Dev5 June 14, 2023 18:54 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch 2 times, most recently from 899a5af to 0875d86 Compare June 14, 2023 19:21
const { orderingProvider: provider } = facility;
const isRequired = requiresOrderProvider(facility.state || "");
const isValidNPI = (npi: string) => {
return /^\d{10}$/.test(npi);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ previously the regex to validate the NPI was /^\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.

@emyl3 emyl3 temporarily deployed to Dev5 June 14, 2023 19:42 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch 2 times, most recently from 0cf185a to 4740da9 Compare June 14, 2023 22:34
@emyl3 emyl3 temporarily deployed to Dev5 June 14, 2023 22:49 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch from 4740da9 to 14e7cee Compare June 14, 2023 22:50
@emyl3 emyl3 temporarily deployed to Dev5 June 14, 2023 23:04 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch from 14e7cee to 6a763fd Compare June 14, 2023 23:55
@emyl3 emyl3 temporarily deployed to Dev5 June 15, 2023 00:11 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch from 6a763fd to 68d7196 Compare June 15, 2023 00:33
@emyl3 emyl3 temporarily deployed to Dev5 June 15, 2023 00:47 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch from 68d7196 to e82824d Compare June 15, 2023 01:45
@emyl3 emyl3 temporarily deployed to Dev5 June 15, 2023 03:37 — with GitHub Actions Inactive
@emyl3 emyl3 force-pushed the elisa/5818-facility-form branch from e82824d to 876fe4b Compare June 15, 2023 04:05
@emyl3 emyl3 temporarily deployed to Dev5 June 15, 2023 13:18 — with GitHub Actions Inactive
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", {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ currently only validating if the facility's zip code and state combination is valid

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) =>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ decided against adding if the zip code was valid for the state validation here because we were making too many requests and getting back 429 errors from SmartyStreets 😅 -- so like it was done before, checking if the zip code and state combination are good only on submit after the form passes initial validation check

@emyl3 emyl3 marked this pull request as ready for review June 15, 2023 14:13
validationStatus={errors?.facility?.email?.type ? "error" : undefined}
errorMessage={errors?.facility?.email?.message}
registrationProps={register("facility.email", {
required: false,
Copy link
Contributor

@BobanL BobanL Jun 15, 2023

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,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooo thank you!

Copy link
Contributor

@johanna-skylight johanna-skylight left a 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",
Copy link
Contributor

@johanna-skylight johanna-skylight Jun 15, 2023

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!

Copy link
Collaborator Author

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={() => {}}
Copy link
Contributor

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?

Copy link
Collaborator Author

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}
Copy link
Contributor

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.

Copy link
Collaborator Author

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!!

@emyl3 emyl3 dismissed stale reviews from johanna-skylight and BobanL via 91a7f96 June 20, 2023 23:47
@emyl3 emyl3 temporarily deployed to Dev5 June 21, 2023 00:19 — with GitHub Actions Inactive
@fzhao99 fzhao99 self-requested a review June 21, 2023 13:23
@fzhao99 fzhao99 dismissed their stale review June 21, 2023 13:27

got more clarity on co edge case

@fzhao99 fzhao99 removed their request for review June 21, 2023 13:28
@emyl3 emyl3 temporarily deployed to Dev5 June 21, 2023 21:04 — with GitHub Actions Inactive
@emyl3 emyl3 temporarily deployed to Dev5 June 21, 2023 23:08 — with GitHub Actions Inactive
BobanL
BobanL previously approved these changes Jun 22, 2023
Copy link
Contributor

@BobanL BobanL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@emyl3 emyl3 temporarily deployed to Dev5 June 22, 2023 14:56 — with GitHub Actions Inactive
@emyl3 emyl3 dismissed stale reviews from johanna-skylight and BobanL via 791727f June 22, 2023 16:04
@emyl3 emyl3 temporarily deployed to Dev5 June 22, 2023 16:28 — with GitHub Actions Inactive
@emyl3
Copy link
Collaborator Author

emyl3 commented Jun 22, 2023

@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!!
on dev5 for testing!
Screenshot 2023-06-22 at 11 41 56

Copy link
Contributor

@fzhao99 fzhao99 left a 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!

@sonarcloud
Copy link

sonarcloud bot commented Jun 22, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.8% 90.8% Coverage
0.0% 0.0% Duplication

@emyl3 emyl3 merged commit 7a7363d into main Jun 22, 2023
@emyl3 emyl3 deleted the elisa/5818-facility-form branch June 22, 2023 22:12
@emyl3 emyl3 mentioned this pull request Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Add Facility] Form not using proper element and error messages are not clear.
4 participants