🛠️ Replace useDispatch
with useQuery
/request
#6316
Closed
22 tasks done
Labels
useDispatch
with useQuery
/request
#6316
Currently, we are using
useDispatch
to dispatch actions throughfireRequest
. We need to migrate this to useuseQuery
(for performing GET requests on component mount) andrequest
to perform API calls of other methods (such as form submissions, etc.)📖 References for the
request
anduseQuery
data fetching utilitiesuseDispatch
to useuseQuery
(inherently fixes camera not reloading on configure saved) #6327Tasks
Feel free to split these individual tasks further into multiple sub-tasks/PRs if the refactor is large. It will be easier to do the refactor, QA testing, and code review.
useDispatch
w.useQuery
/request
: ABDM (src/Components/ABDM/**
) #6330useDispatch
w.useQuery
/request
: Assets (src/Components/Assets/**
) #6326useDispatch
w.useQuery
/request
: Auth (src/Components/Auth/**
) #6331useDispatch
w.useQuery
/request
: DeathReport (src/Components/DeathReport/**
) #6328useDispatch
w.useQuery
/request
: ExternalResult (src/Components/ExternalResult/**
) #6360useDispatch
w.useQuery
/request
: Consultations (src/Components/Facility/Consultations/**
) #6372useDispatch
w.useQuery
/request
: Facility (Part 1, A-D) (src/Components/Facility/*
) #6376useDispatch
w.useQuery
/request
: Facility (Part 2, E-H) (src/Components/Facility/[E-H]*.tsx
) #6391useDispatch
w.useQuery
/request
: Medicine (src/Components/Medicine/**
) #6442useDispatch
w.useQuery
/request
: Notifications (src/Components/Notifications/**
) #6392useDispatch
w.useQuery
/request
: Patient (src/Components/Patient/**
) #6546useDispatch
w.useQuery
/request
: Resource (src/Components/Resource/**
) #6443useDispatch
w.useQuery
/request
: Shifting (src/Components/Shifting/**
) #6483useDispatch
w.useQuery
/request
: Common (src/Components/Common/**
) #6888useDispatch
w.useQuery
/request
: Investigations (src/Components/Facility/Investigations
) #7168useDispatch
w.useQuery
/request
: Daily Rounds form (src/Components/Patient/DailyRounds.tsx
) #7169useDispatch
w.useQuery
/request
: File Upload (src/Components/Patient/FileUpload.tsx
) #7170useDispatch
w.useQuery
/request
: Patient Registration Form (src/Components/Patient/PatientRegister.tsx
) #7171Steps to follow
from "react-redux"
and specify the corresponding files to include regex as shownIn all of the files in the search results, you'll have to remove the usage of
useDispatch
(and corresponding actions that are dispatched) and replace it withuseQuery
andrequest
appropriately.All of the existing routes are available at
src/Redux/api.tsx
which can be passed to theuseQuery/request
directly.For each route that is being used, ensure the response type is also present. If not, you'll have to add it.
Example:
Delete the relevant no longer used actions from
actions.tsx
. (Ensure the action is not used outside the scope of the migration too)You'll also need to add cypress tests if existing cypress tests do not cover pages/components where the replacements are being done.
The text was updated successfully, but these errors were encountered: