From 5f4ba608f564e6a324c61c4596cef4be8bce22dc Mon Sep 17 00:00:00 2001 From: Sulochan Khadka <122200551+Sulochan-khadka@users.noreply.github.com> Date: Sat, 12 Oct 2024 02:29:40 +0530 Subject: [PATCH] Fixes:Non-admin-access-to-consultation-page --- src/Components/Facility/ConsultationCard.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Components/Facility/ConsultationCard.tsx b/src/Components/Facility/ConsultationCard.tsx index f6ef18f5c1f..8cf7c899ffd 100644 --- a/src/Components/Facility/ConsultationCard.tsx +++ b/src/Components/Facility/ConsultationCard.tsx @@ -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; @@ -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 ( <> { `/facility/${itemData.facility}/patient/${itemData.patient}/consultation/${itemData.id}`, ) } - disabled={!!authuser} + disabled={ + !facilities?.some((item) => item.name === itemData.facility_name) + } > View Consultation / Consultation Updates @@ -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