Skip to content

Commit

Permalink
Fixes:Non-admin-access-to-consultation-page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sulochan-khadka committed Oct 11, 2024
1 parent 41d4798 commit 5f4ba60
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Components/Facility/ConsultationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { useState } from "react";
import DialogModal from "../Common/Dialog.js";
import Beds from "./Consultations/Beds";
import careConfig from "@careConfig";
import useAuthUser from "../../Common/hooks/useAuthUser";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";

interface ConsultationProps {
itemData: ConsultationModel;
Expand All @@ -21,13 +22,12 @@ interface ConsultationProps {
export const ConsultationCard = (props: ConsultationProps) => {
const { itemData, isLastConsultation, refetch } = props;
const [open, setOpen] = useState(false);
const { user_type } = useAuthUser();
const authuser = user_type == "Nurse";
const bedDialogTitle = itemData.discharge_date
? "Bed History"
: !itemData.current_bed
? "Assign Bed"
: "Switch Bed";
const facilities = useQuery(routes.getPermittedFacilities).data?.results;
return (
<>
<DialogModal
Expand Down Expand Up @@ -176,7 +176,9 @@ export const ConsultationCard = (props: ConsultationProps) => {
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}`,
)
}
disabled={!!authuser}
disabled={
!facilities?.some((item) => item.name === itemData.facility_name)
}
>
View Consultation / Consultation Updates
</ButtonV2>
Expand All @@ -187,7 +189,9 @@ export const ConsultationCard = (props: ConsultationProps) => {
`/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}/files/`,
)
}
disabled={!!authuser}
disabled={
!facilities?.some((item) => item.name === itemData.facility_name)
}
>
View / Upload Consultation Files
</ButtonV2>
Expand Down

0 comments on commit 5f4ba60

Please sign in to comment.