Skip to content

Commit

Permalink
disable all options except Destination Approved for non-admin desti…
Browse files Browse the repository at this point in the history
…nation facility users
  • Loading branch information
khavinshankar committed Jun 10, 2024
1 parent ed007e9 commit 136b82c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Components/Shifting/ShiftDetailsUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SHIFTING_CHOICES_PEACETIME,
SHIFTING_CHOICES_WARTIME,
SHIFTING_VEHICLE_CHOICES,
USER_TYPES,
} from "../../Common/constants";
import { Cancel, Submit } from "../Common/components/ButtonV2";

Expand Down Expand Up @@ -39,6 +40,7 @@ import routes from "../../Redux/api.js";
import { IShift } from "./models.js";
import request from "../../Utils/request/request.js";
import { PatientModel } from "../Patient/models.js";
import useAuthUser from "../../Common/hooks/useAuthUser.js";

const Loading = lazy(() => import("../Common/Loading"));

Expand All @@ -48,6 +50,7 @@ interface patientShiftProps {

export const ShiftDetailsUpdate = (props: patientShiftProps) => {
const { goBack } = useAppHistory();
const { user_type, home_facility } = useAuthUser();

const { kasp_full_string, kasp_enabled, wartime_shifting } = useConfig();

Expand Down Expand Up @@ -338,6 +341,13 @@ export const ShiftDetailsUpdate = (props: patientShiftProps) => {
value={state.form.status}
optionLabel={(option) => option.text}
optionValue={(option) => option.text}
optionDisabled={(option) =>
// disable all options except `Destination Approved` for non-admin destination facility users
home_facility === state.form.assigned_facility_object?.id &&
USER_TYPES.findIndex((type) => user_type === type) <
USER_TYPES.findIndex((type) => type === "DistrictAdmin") &&
!["DESTINATION APPROVED"].includes(option.text)
}
optionSelectedLabel={(option) => option.text}
onChange={handleFormFieldChange}
className="w-full bg-white md:col-span-1 md:leading-5"
Expand Down

0 comments on commit 136b82c

Please sign in to comment.