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 w. useQuery/request: Resource (src/Components/Resource/**) #6461

Merged
merged 18 commits into from
Oct 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix naming
konavivekramakrishna committed Oct 26, 2023
commit 136f375e09db40cbafe5a6f6e44483715690ea4a
20 changes: 6 additions & 14 deletions src/Components/Resource/BadgesList.tsx
Original file line number Diff line number Diff line change
@@ -11,13 +11,9 @@ function useFacilityQuery(facilityId: string | undefined) {

export default function BadgesList(props: any) {
const { appliedFilters, FilterBadges } = props;
const originFacilityData = useFacilityQuery(appliedFilters.origin_facility);
const approvingFacilityData = useFacilityQuery(
appliedFilters.approving_facility
);
const assignedFacilityData = useFacilityQuery(
appliedFilters.assigned_facility
);
const originFacility = useFacilityQuery(appliedFilters.origin_facility);
const approvingFacility = useFacilityQuery(appliedFilters.approving_facility);
const assignedFacility = useFacilityQuery(appliedFilters.assigned_facility);

const getDescShiftingFilterOrder = (ordering: any) => {
const foundItem = SHIFTING_FILTER_ORDER.find(
@@ -41,20 +37,16 @@ export default function BadgesList(props: any) {
}),
...dateRange("Modified", "modified_date"),
...dateRange("Created", "created_date"),
value(
"Origin facility",
"origin_facility",
originFacilityData?.data?.name
),
value("Origin facility", "origin_facility", originFacility?.data?.name),
value(
"Approving facility",
"approving_facility",
approvingFacilityData?.data?.name
approvingFacility?.data?.name
),
value(
"Assigned facility",
"assigned_facility",
assignedFacilityData?.data?.name
assignedFacility?.data?.name
),
]}
/>
6 changes: 3 additions & 3 deletions src/Components/Resource/ResourceDetailsUpdate.tsx
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
dispatch({ type: "set_form", form });
};

const { data: resourceDetailsData } = useQuery(routes.getResourceDetails, {
const { data: resourceDetails } = useQuery(routes.getResourceDetails, {
pathParams: { id: props.id },
onResponse: ({ res, data }) => {
if (res && data) {
@@ -159,7 +159,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
assigned_quantity:
state.form.status === "PENDING"
? state.form.assigned_quantity
: resourceDetailsData?.assigned_quantity || 0,
: resourceDetails?.assigned_quantity || 0,
};

const { res, data } = await request(routes.updateResource, {
@@ -189,7 +189,7 @@ export const ResourceDetailsUpdate = (props: resourceProps) => {
<Page
title="Update Resource Request"
backUrl={`/resource/${props.id}`}
crumbsReplacements={{ [props.id]: { name: resourceDetailsData?.title } }}
crumbsReplacements={{ [props.id]: { name: resourceDetails?.title } }}
>
<div className="mt-4">
<Card className="flex w-full flex-col">
5 changes: 4 additions & 1 deletion src/Redux/api.tsx
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ import {
AssetUpdate,
} from "../Components/Assets/AssetTypes";
import {
ConsultationModel,
FacilityModel,
LocationModel,
WardModel,
@@ -42,9 +43,11 @@ import {
} from "../Components/ExternalResult/models";

import { Prescription } from "../Components/Medicine/models";

import { UserModel } from "../Components/Users/models";
import { PaginatedResponse } from "../Utils/request/types";
import { PatientModel } from "../Components/Patient/models";
import { IComment, IResource } from "../Components/Resource/models";

/**
* A fake function that returns an empty object casted to type T