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 useDipatch with useQuery/request in FacilityCreate and HospitalList files #6591

Merged
merged 24 commits into from
Dec 28, 2023

Conversation

sriharsh05
Copy link
Contributor

@sriharsh05 sriharsh05 commented Nov 13, 2023

WHAT

🤖 Generated by Copilot at 1aefc25

Refactored some components in the Facility module to use the request function and the useQuery hook for making and fetching API calls. Added and used some types to ensure type safety and consistency for the data from the backend. Removed some unnecessary code and fixed some minor issues.

The pull request partially refactors the codebase for managing facility module in the frontend. It replaces the redux actions and states with the custom request function and the useQuery hook for data fetching and updating. It improves the code quality, performance, and readability by removing unnecessary imports, variables, and dependencies.

This pull request makes the required changes to only 2 files and does not close the entire issue.

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 1aefc25

  • Refactored the FacilityCreate component to use the request function and the useQuery hook for fetching data from the API and removed the useAbortableEffect hook and the dispatchAction function (link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Updated the data variable in the FacilityCreate component to match the API schema and removed the unnecessary properties (link, link)
  • Added a type check for the district property in the fetchedDistricts array in the FacilityCreate component to avoid errors (link)
  • Converted the id variable to a string before setting it as the createdFacilityId state in the FacilityCreate component (link)
  • Removed the error handling logic from the FacilityCreate component as it was handled by the request function internally (link)
  • Refactored the HospitalList component to use the useQuery hook for fetching data from the API and removed the useAbortableEffect hook, the dispatchAction function and the totalCount variable (link, link, link, link, link, link, link, link)
  • Replaced the stateName, districtName and localbodyName variables with the stateData, districtData and localBodyData variables in the HospitalList component to display the state, district and local body names from the data returned by the useQuery hook (link)
  • Added the IStateListResponse type to the ./models file to define the type of the response returned by the API for listing the states (link)
  • Imported the FacilityModel, CapacityModal, DoctorModal, DistrictModel, LocalBodyModel, StateModel and IStateListResponse types from ./models to use in the routes object in the ./api file (link, link)
  • Added the TRes property to the createFacility, updateFacility, getCapacity, listDoctor, statesList, getState, getDistrict, getDistrictByState and getLocalBody routes in the routes object in the ./api file to define the type of the response returned by the API for each endpoint (link, link, link, link, link, link, link)

@sriharsh05 sriharsh05 requested a review from a team November 13, 2023 07:18
@sriharsh05 sriharsh05 requested a review from a team as a code owner November 13, 2023 07:18
Copy link

vercel bot commented Nov 13, 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 Dec 27, 2023 6:29am

Copy link

netlify bot commented Nov 13, 2023

Deploy Preview for care-egov-staging ready!

Name Link
🔨 Latest commit 2f2c19d
🔍 Latest deploy log https://app.netlify.com/sites/care-egov-staging/deploys/658bc406f580f40008e81d8a
😎 Deploy Preview https://deploy-preview-6591--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.

@sriharsh05
Copy link
Contributor Author

@rithviknishad
Please review this PR.

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

👋 Hi, @sriharsh05,
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.

@rithviknishad
Copy link
Member

@sriharsh05 the cypress is failing

@rithviknishad rithviknishad added cypress failed pull request with cypress test failure and removed merge conflict pull requests with merge conflict labels Nov 14, 2023
@rithviknishad
Copy link
Member

@sriharsh05

@sriharsh05
Copy link
Contributor Author

@sriharsh05

I'll look into it @rithviknishad

@sriharsh05
Copy link
Contributor Author

@rithviknishad Please review the code.

src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
src/Components/Facility/FacilityCreate.tsx Outdated Show resolved Hide resolved
@rithviknishad
Copy link
Member

@sriharsh05 cypress tests are still failing

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

👋 Hi, @sriharsh05,
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.

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

👋 Hi, @sriharsh05,
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.

@nihal467
Copy link
Member

@sriharsh05 can you clear the merge conflict

@sriharsh05
Copy link
Contributor Author

@rithviknishad
Please review the changes.

@rithviknishad rithviknishad added needs testing and removed changes required merge conflict pull requests with merge conflict labels Dec 21, 2023
@nihal467
Copy link
Member

nihal467 commented Dec 26, 2023

image

  • the above screenshot is the deploy preview

image

  • the above screenshot is the current staging

  • @sriharsh05 As you can see, in the deploy preview the facility homepage is not loaded properly as the total facility card loading state is missing, fix the issue

@khavinshankar khavinshankar merged commit 3c008b2 into ohcnetwork:develop Dec 28, 2023
24 of 26 checks passed
Copy link

@sriharsh05 We truly appreciate your efforts. Thank you for taking the time to contribute; this is a very valuable contribution to us 🥇. We always welcome your contribution 🙂, so feel free to contribute to anything anytime, and never lose that spirit of innovation 🙌.

Ashesh3 pushed a commit that referenced this pull request Jan 2, 2024
…talList files (#6591)

* Replaced useDipatch with useQuery/request in FacilityCreate and HospitalList files

* fix failing api calls

* replace function with request calls with useQuery

* remove useState variables and used variables from useQuery

* fix facility pincode issue

* fix longitude and latitude for facility and optimized code

* Fixed ward list bug

* fix auto fill for pincode bug

* remove duplicate request

* fix total facility card loading state

* fix clear filter badges bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🛠️ Replace useDispatch w. useQuery/request: Facility (Part 2, E-H) (src/Components/Facility/[E-H]*.tsx)
4 participants