Skip to content

Commit

Permalink
changed prefetch condition
Browse files Browse the repository at this point in the history
  • Loading branch information
konavivekramakrishna committed Nov 5, 2023
1 parent ffcb37d commit 910df57
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
11 changes: 8 additions & 3 deletions src/Components/Shifting/BadgesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import { SHIFTING_FILTER_ORDER } from "../../Common/constants";
import { useTranslation } from "react-i18next";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import { UserModel } from "../Users/models";

function useFacilityQuery(facilityId: string | undefined) {
return useQuery(routes.getAnyFacility, {
pathParams: { id: String(facilityId) },
prefetch: facilityId !== undefined,
pathParams: { id: facilityId as string },
prefetch: !!facilityId,
});
}

export function namereturn(user: UserModel) {
return `${user.first_name || ""} ${user.last_name || ""}`;
}

export default function BadgesList(props: any) {
const { qParams, FilterBadges } = props;

Expand All @@ -23,7 +28,7 @@ export default function BadgesList(props: any) {

const { data: assignedUser } = useQuery(routes.userList, {
query: { id: qParams.assigned_to },
prefetch: qParams.assigned_to ? true : false,
prefetch: !!qParams.assigned_to,
});
const originFacility = useFacilityQuery(qParams.origin_facility);
const approvingFacility = useFacilityQuery(
Expand Down
6 changes: 1 addition & 5 deletions src/Components/Shifting/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export interface IShift {
is_assigned_to_user: boolean;
created_by: number;
last_edited_by: number;
patient: string;
patient: string | PatientModel;
initial_status?: string;
}

export interface IShiftDetails extends Omit<IShift, "patient"> {
patient: PatientModel;
}
4 changes: 2 additions & 2 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ 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";
import { IShift, IShiftDetails } from "../Components/Shifting/models";
import { IShift } from "../Components/Shifting/models";

/**
* A fake function that returns an empty object casted to type T
Expand Down Expand Up @@ -758,7 +758,7 @@ const routes = {
getShiftDetails: {
path: "/api/v1/shift/{id}/",
method: "GET",
TRes: Type<IShiftDetails>(),
TRes: Type<IShift>(),
},
completeTransfer: {
path: "/api/v1/shift/{externalId}/transfer/",
Expand Down

0 comments on commit 910df57

Please sign in to comment.