Skip to content

Commit

Permalink
adds nurse user type, fixes #6240
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Oct 18, 2023
1 parent 9b362c1 commit ba07f48
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Authenticate to staging API with any of the following credentials

- username: staffdev
password: Coronasafe@123
role: Staff
role: Nurse

- username: doctordev
password: Coronasafe@123
Expand Down
22 changes: 4 additions & 18 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export type UserRole =
| "Volunteer"
| "StaffReadOnly"
| "Staff"
| "NurseReadOnly"
| "Nurse"
| "Doctor"
| "WardAdmin"
| "LocalBodyAdmin"
Expand All @@ -47,6 +49,8 @@ export const USER_TYPE_OPTIONS: {
{ id: "Volunteer", role: "Volunteer", readOnly: false },
{ id: "StaffReadOnly", role: "Staff", readOnly: true },
{ id: "Staff", role: "Staff", readOnly: false },
{ id: "NurseReadOnly", role: "Nurse", readOnly: true },
{ id: "Nurse", role: "Nurse", readOnly: false },
{ id: "Doctor", role: "Doctor", readOnly: false },
{ id: "WardAdmin", role: "Ward Admin", readOnly: false },
{ id: "LocalBodyAdmin", role: "Local Body Admin", readOnly: false },
Expand Down Expand Up @@ -410,24 +414,6 @@ export const SAMPLE_FLOW_RULES = {
RECEIVED_AT_LAB: ["COMPLETED"],
};

export const ROLE_STATUS_MAP = {
Staff: ["SENT_TO_COLLECTON_CENTRE"],
DistrictAdmin: [
"APPROVED",
"DENIED",
"SENT_TO_COLLECTON_CENTRE",
"RECEIVED_AND_FORWARED",
],
StateLabAdmin: [
"APPROVED",
"DENIED",
"SENT_TO_COLLECTON_CENTRE",
"RECEIVED_AND_FORWARED",
"RECEIVED_AT_LAB",
"COMPLETED",
],
};

export const DISEASE_STATUS = [
"POSITIVE",
"SUSPECTED",
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/DoctorVideoSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default function DoctorVideoSlideover(props: {
home: true,
},
{
title: "Staff",
user_type: "Staff",
title: "Nurse",
user_type: "Nurse",
home: true,
},
{
Expand Down
31 changes: 16 additions & 15 deletions src/Components/Users/UserAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ const initForm: UserForm = {
doctor_medical_council_registration: undefined,
};

const STAFF_OR_NURSE_USER = [
"Staff",
"StaffReadOnly",
"Nurse",
"NurseReadOnly",
];

const initError = Object.assign(
{},
...Object.keys(initForm).map((k) => ({ [k]: "" }))
Expand Down Expand Up @@ -246,13 +253,12 @@ export const UserAdd = (props: UserProps) => {

const headerText = !userId ? "Add User" : "Update User";
const buttonText = !userId ? "Save User" : "Update Details";
const showLocalbody = !(
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 showLocalbody = ![
"Pharmacist",
"Volunteer",
"Doctor",
...STAFF_OR_NURSE_USER,
].includes(state.form.user_type);

const fetchDistricts = useCallback(
async (id: number) => {
Expand Down Expand Up @@ -340,10 +346,7 @@ export const UserAdd = (props: UserProps) => {
useAbortableEffect(
(status: statusType) => {
fetchStates(status);
if (
authUser.user_type === "Staff" ||
authUser.user_type === "StaffReadOnly"
) {
if (STAFF_OR_NURSE_USER.includes(authUser.user_type)) {
fetchFacilities(status);
}
},
Expand Down Expand Up @@ -398,10 +401,8 @@ export const UserAdd = (props: UserProps) => {
case "facilities":
if (
state.form[field].length === 0 &&
(authUser.user_type === "Staff" ||
authUser.user_type === "StaffReadOnly") &&
(state.form["user_type"] === "Staff" ||
state.form["user_type"] === "StaffReadOnly")
STAFF_OR_NURSE_USER.includes(authUser.user_type) &&
STAFF_OR_NURSE_USER.includes(state.form.user_type)
) {
errors[field] =
"Please select atleast one of the facilities you are linked to";
Expand Down

0 comments on commit ba07f48

Please sign in to comment.