Skip to content

Commit

Permalink
fixes #7002; restrict access to external results for Nurse and Staff
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Jan 11, 2024
1 parent 83aa8be commit 8a5df57
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/Components/ExternalResult/ResultList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import Page from "../Common/components/Page";
import routes from "../../Redux/api";
import useQuery from "../../Utils/request/useQuery";
import { parsePhoneNumber } from "../../Utils/utils";
import useAuthUser from "../../Common/hooks/useAuthUser";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
const Loading = lazy(() => import("../Common/Loading"));

export default function ResultList() {
const authUser = useAuthUser();
const {
qParams,
updateQuery,
Expand Down Expand Up @@ -165,6 +168,10 @@ export default function ResultList() {
<td className="whitespace-nowrap px-6 py-4 text-left text-sm leading-5 text-gray-500">
<ButtonV2
variant="primary"
disabled={
authUser.user_type === "Nurse" || authUser.user_type === "Staff"
}
authorizeFor={NonReadOnlyUsers}
border
ghost
onClick={() => {
Expand Down Expand Up @@ -226,13 +233,18 @@ export default function ResultList() {
<ExportMenu
label="Import/Export"
exportItems={[
{
label: "Import Results",
action: () => navigate("/external_results/upload"),
options: {
icon: <CareIcon className="care-l-import" />,
},
},
...(authUser.user_type !== "Nurse" &&
authUser.user_type !== "Staff"
? [
{
label: "Import Results",
action: () => navigate("/external_results/upload"),
options: {
icon: <CareIcon className="care-l-import" />,
},
},
]
: []),
{
label: "Export Results",
action: () =>
Expand Down
6 changes: 6 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import useConfig from "../../Common/hooks/useConfig";
import { useDispatch } from "react-redux";
import { validatePincode } from "../../Common/validation";
import { FormContextValue } from "../Form/FormContext.js";
import useAuthUser from "../../Common/hooks/useAuthUser.js";

const Loading = lazy(() => import("../Common/Loading"));
const PageTitle = lazy(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -180,6 +181,7 @@ const patientFormReducer = (state = initialState, action: any) => {
};

export const PatientRegister = (props: PatientRegisterProps) => {
const authUser = useAuthUser();
const { goBack } = useAppHistory();
const { gov_data_api_key, enable_hcx, enable_abdm } = useConfig();
const dispatchAction: any = useDispatch();
Expand Down Expand Up @@ -1173,6 +1175,10 @@ export const PatientRegister = (props: PatientRegisterProps) => {
<div className="mb-2 overflow-visible rounded border border-gray-200 p-4">
<ButtonV2
className="flex items-center gap-2"
disabled={
authUser.user_type === "Nurse" ||
authUser.user_type === "Staff"
}
onClick={(_) => {
setShowImport({
show: true,
Expand Down

0 comments on commit 8a5df57

Please sign in to comment.