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

Replaced useDispatch with useQuery and request. #6344

Merged
merged 11 commits into from
Oct 18, 2023

Conversation

shyamprakash123
Copy link
Contributor

@shyamprakash123 shyamprakash123 commented Sep 25, 2023

WHAT

🤖 Generated by Copilot at 741fbac

Refactored ABDM components to use request utility and ABDM API routes. Added ABDM API support in api.tsx and models.ts.

Proposed Changes

@coronasafe/care-fe-code-reviewers @coronasafe/code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

HOW

🤖 Generated by Copilot at 741fbac

  • Refactor the ABDM components to use the custom request and query utilities and the ABDM API routes (F0, F1, F2, F3)
  • Remove the unused imports of useDispatch and various ABDM actions from the ABDM components (link, link, link, link, link, link, link)
  • Add the imports of request, useQuery, and routes to the ABDM components to use the custom request and query utilities and the API routes for the ABDM module (link, link, link, link)
  • Replace the dispatch actions with the request utility to fetch or update the data from the ABDM API endpoints, and destructure the response and data variables from the request result (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Use the data variable to populate the success data, generate the QR code and the download link, show the notification or error messages, and call the callback functions (link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Replace the dispatch action with the useQuery utility to fetch the health facility data, and destructure the health_facility, loading, and refetch variables from the useQuery result (link)
  • Use the health_facility variable to populate the form data, and use the refetch function to refetch the data on mount or update (link)
  • Use the loading and isLoading variables to render the loading component (link)
  • Define the IHealthFacility, ILinkABHANumber, IConfirmMobileOtp, IHealthId, IAadhaarOtp, ICheckAndGenerateMobileOtp, and ICreateHealthIdResponse interfaces to specify the expected response types for the ABDM API endpoints (link)
  • Import the ABDM interfaces from the ./src/Components/ABDM/models.ts file (link)
  • Define the abha property with the ABDM API routes, such as getAbhaCard, linkAbhaNumber, confirmMobileOtp, createHealthId, generateAadhaarOtp, checkAndGenerateMobileOtp, and verifyAadhaarOtp (link)
  • Include the TRes property for each route, which specifies the expected response type for each route, such as IHealthFacility, ILinkABHANumber, IConfirmMobileOtp, IHealthId, IAadhaarOtp, ICheckAndGenerateMobileOtp, and ICreateHealthIdResponse (link)

@vercel
Copy link

vercel bot commented Sep 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
care-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2023 1:18am

@netlify
Copy link

netlify bot commented Sep 25, 2023

Deploy Preview for care-egov-staging ready!

Name Link
🔨 Latest commit b56daee
🔍 Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/652f324b56d41c00089c9bd9
😎 Deploy Preview https://deploy-preview-6344--care-egov-staging.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@khavinshankar khavinshankar left a comment

Choose a reason for hiding this comment

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

LGTM, why was package-lock.json changed?

@rithviknishad can you review this pr once

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

Nice work on nesting the ABDM related routes under abdm.

image
  • You'll also have to untrack your package-lock.json changes

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

You'll also have to add TBody type definitions for all mutation routes such as (POST PUT PATCH DELETE).

9bc19ed Adds support for it. so you'll have to rebase with the latest develop too in order to do that.

@shyamprakash123
Copy link
Contributor Author

You'll also have to add TBody type definitions for all mutation routes such as (POST PUT PATCH DELETE).

9bc19ed Adds support for it. so you'll have to rebase with the latest develop too in order to do that.

All mutation routes mean only for the Abha routes right?

@rithviknishad
Copy link
Member

yes @shyamprakash123

@shyamprakash123
Copy link
Contributor Author

Ready for the review.

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

  • You shouldn't delete package-lock
  • rename: Tbody to TBody.
  • Avoid declaring types in api.tsx. Consider declaring them in ABDM's models.ts file itself. Also, you can reuse existing types instead of creating seperate types for TBody. You can share types by making some unavailable fields to take value undefined

Eg:

export interface Model {
  read_and_write_available_filed: string;
  readonly available_only_for_read?: string;
}

@shyamprakash123
Copy link
Contributor Author

Ready for the review.

@shyamprakash123
Copy link
Contributor Author

@shyamprakash123 image

  • I am unable to link Abha in the patient creation page, even after the mobile number was given, it is throwing an error, the field can't be empty

CC: @rithviknishad

@nihal467,

Fixed Errors -

  • unable to link Abha in the patient creation page, even after the mobile number was given, it is throwing an error, the field can't be empty.
  • Replaced Rdata with Rerror.

CC: @rithviknishad

@khavinshankar
Copy link
Member

@nihal467 I think the errors are fixed, can you recheck this

cc: @shyamprakash123 @rithviknishad

@nihal467
Copy link
Member

nihal467 commented Oct 16, 2023

@shyamprakash123
image

in the patient consultation page, once we enter the aadhar number, it is not getting redirected to the otp section

@nihal467 nihal467 added test failed and removed needs testing reviewed reviewed by a core member labels Oct 16, 2023
@shyamprakash123
Copy link
Contributor Author

shyamprakash123 commented Oct 17, 2023

@shyamprakash123 image

in the patient consultation page, once we enter the aadhar number, it is not getting redirected to the otp section

@nihal467 I just checked the ABHA Link for the patient consultation page it is working as expected.
You can check the video I recorded while testing the linking of ABHA it is redirecting me to the OTP section.
So, I'm requesting you to once again re-test this PR.
Video link - https://www.loom.com/share/2684ce0ebfa24a18bcea3fc446c9d991
CC: @rithviknishad @khavinshankar

@nihal467
Copy link
Member

LGTM

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Oct 18, 2023
@github-actions
Copy link

👋 Hi, @shyamprakash123,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@khavinshankar khavinshankar merged commit d26aba5 into coronasafe:develop Oct 18, 2023
53 of 57 checks passed
Ashesh3 pushed a commit that referenced this pull request Oct 20, 2023
* Replaced useDispatch with useQuery and request.

* Removed all relevant no longer used actions from actions.tsx

* Replaced Res to Type

* Added TBody.

* used abha in place of JSON.parse(value).

* Fixed mobile otp issue

* Replaced Rdata with Rerror

* Fixed link care context

---------

Co-authored-by: Khavin Shankar <khavinshankar@gmail.com>
Ashesh3 pushed a commit that referenced this pull request Oct 23, 2023
* Replaced useDispatch with useQuery and request.

* Removed all relevant no longer used actions from actions.tsx

* Replaced Res to Type

* Added TBody.

* used abha in place of JSON.parse(value).

* Fixed mobile otp issue

* Replaced Rdata with Rerror

* Fixed link care context

---------

Co-authored-by: Khavin Shankar <khavinshankar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🛠️ Replace useDispatch w. useQuery/request: ABDM (src/Components/ABDM/**)
4 participants