Skip to content

Commit

Permalink
Merge pull request #2274 from coronasafe/create-doctor
Browse files Browse the repository at this point in the history
Access Control; Exception to allow Staff to Create Doctors; Remove Localbody for Doctor; Pharmacists; Volunteers
  • Loading branch information
gigincg authored Apr 27, 2022
2 parents 2987f5f + 2a6ab5c commit c111973
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Components/Users/UserAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ export const UserAdd = (props: UserProps) => {
const userType = currentUser.data.user_type;

const userIndex = USER_TYPES.indexOf(userType);

const defaultAllowedUserTypes = USER_TYPES.slice(0, userIndex + 1);

const userTypes = isSuperuser
? [...USER_TYPES]
: userType === "StaffReadOnly"
Expand All @@ -149,12 +152,19 @@ export const UserAdd = (props: UserProps) => {
? ["StaffReadOnly", "DistrictReadOnlyAdmin", "StateReadOnlyAdmin"]
: userType === "Pharmacist"
? ["Pharmacist"]
: USER_TYPES.slice(0, userIndex + 1);
: // Exception to allow Staff to Create Doctors
userType === "Staff"
? ["Doctor", ...defaultAllowedUserTypes]
: defaultAllowedUserTypes;

const headerText = !userId ? "Add User" : "Update User";
const buttonText = !userId ? "Save User" : "Update Details";
const showLocalbody = !(
state.form.user_type === "Staff" || state.form.user_type === "StaffReadOnly"
state.form.user_type === "Pharmacist" ||
state.form.user_type === "Volunteer" ||
state.form.user_type === "Doctor" ||
state.form.user_type === "Staff" ||
state.form.user_type === "StaffReadOnly"
);

const fetchDistricts = useCallback(
Expand Down

0 comments on commit c111973

Please sign in to comment.