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

(feat) O3-4221: Use react hook form and zod in the queue service form #1416

Conversation

Muppasanipraneeth
Copy link
Contributor

@Muppasanipraneeth Muppasanipraneeth commented Dec 17, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR refactors the existing form validation logic to use Zod, a TypeScript-first schema validation library. The refactor provides the following benefits:

  • Type-safe validation: Ensures better alignment with TypeScript types.
  • Simplified logic: Reduces the complexity of form validation.
  • Improved developer experience: Allows for inline schema definitions.
  • Reduced boilerplate: Removes manual validation code.

Key Changes

  1. Introduced a zod schema to define form validation logic.
  2. Replaced manual validation processes with schema-based validation.
  3. Updated test cases to align with the new Zod-based validation approach.

Screenshots

See below in PR thread

Related Issue

Other Notes

  • Minimal impact on the behavior of existing components.
  • Performance improvements by leveraging Zod's efficient validation mechanisms.

@denniskigen denniskigen changed the title Refactor/o3 4221 replace validation with zod (refactor) O3-4221: service-queues: Use zod for validation in the queue service form Dec 17, 2024
@denniskigen denniskigen changed the title (refactor) O3-4221: service-queues: Use zod for validation in the queue service form (refactor) O3-4221: service-queues: Use react-hook-form and zod in the queue service form Dec 17, 2024
Copy link
Member

@denniskigen denniskigen left a comment

Choose a reason for hiding this comment

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

Great start, @Muppasanipraneeth. Left a few comments that should be straightforward to address.

@Muppasanipraneeth
Copy link
Contributor Author

@denniskigen as you said made changes

Copy link
Member

@denniskigen denniskigen left a comment

Choose a reason for hiding this comment

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

Thanks for getting this off the ground, @Muppasanipraneeth. I've left some comments.

@Muppasanipraneeth
Copy link
Contributor Author

This is before using Carbon's built-in error handling means while using InlineNotification

Screen.Recording.2024-12-22.at.10.08.20.PM.mov

This is after using Carbon's built-in error handling

Screen.Recording.2024-12-22.at.10.04.52.PM.mov

@Muppasanipraneeth
Copy link
Contributor Author

@denniskigen

@denniskigen denniskigen force-pushed the refactor/O3-4221-replace-validation-with-zod branch from 8049b23 to f2724f9 Compare December 23, 2024 18:50
@denniskigen denniskigen changed the title (refactor) O3-4221: service-queues: Use react-hook-form and zod in the queue service form (feat) O3-4221: Use react hook form and zod in the queue service form Dec 23, 2024
@denniskigen denniskigen force-pushed the refactor/O3-4221-replace-validation-with-zod branch from f2724f9 to 163daef Compare December 23, 2024 19:17
Copy link
Member

@denniskigen denniskigen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@denniskigen denniskigen merged commit 1689ede into openmrs:main Dec 23, 2024
6 checks passed
@Muppasanipraneeth
Copy link
Contributor Author

Thanks @denniskigen

@gracepotma
Copy link
Contributor

Thank you very much @Muppasanipraneeth for this work - I especially appreciated your detailed PR description and the before vs after videos :D Keep up the good work!

@Muppasanipraneeth
Copy link
Contributor Author

Thank you very much @Muppasanipraneeth for this work - I especially appreciated your detailed PR description and the before vs after videos :D Keep up the good work!

@gracepotma thanks for appreciating and for your time😊

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.

3 participants