From 3396457555fe020568aa3c54494c24fbe9c8122c Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Mon, 29 Apr 2024 20:30:23 +0530 Subject: [PATCH 1/5] Hide options user doesn't have access to --- src/Components/Users/ManageUsers.tsx | 115 ++++++++++++++++----------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index d25d6ec1d6c..d740c22c31b 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -109,7 +109,7 @@ export default function ManageUsers() { { prefetch: !!qParams.district, pathParams: { id: qParams.district }, - } + }, ); const addUser = ( @@ -223,7 +223,7 @@ export default function ManageUsers() { aria-label="Online" className={classNames( "inline-block h-2 w-2 shrink-0 rounded-full", - cur_online ? "bg-primary-400" : "bg-gray-300" + cur_online ? "bg-primary-400" : "bg-gray-300", )} > @@ -301,7 +301,7 @@ export default function ManageUsers() { {dayjs().diff( user.doctor_experience_commenced_on, "years", - false + false, )}{" "} years @@ -408,7 +408,7 @@ export default function ManageUsers() { {["DistrictAdmin", "StateAdmin"].includes( - authUser.user_type + authUser.user_type, ) && (
@@ -580,6 +580,7 @@ function UserFacilities(props: { user: any }) { facility?: FacilityModel; isHomeFacility: boolean; }>({ show: false, userName: "", facility: undefined, isHomeFacility: false }); + const authUser = useAuthUser(); const [replaceHomeFacility, setReplaceHomeFacility] = useState<{ show: boolean; @@ -757,24 +758,28 @@ function UserFacilities(props: { user: any }) {
{user?.home_facility_object?.name} -
- -
+ {["DistrictAdmin", "StateAdmin"].includes( + authUser.user_type, + ) && ( +
+ +
+ )}

@@ -799,7 +804,7 @@ function UserFacilities(props: { user: any }) { id={`facility_${i}`} key={`facility_${i}`} className={classNames( - "relative rounded p-2 transition hover:bg-gray-200 focus:bg-gray-200 md:rounded-lg" + "relative rounded p-2 transition hover:bg-gray-200 focus:bg-gray-200 md:rounded-lg", )} >
@@ -809,18 +814,28 @@ function UserFacilities(props: { user: any }) { className="tooltip text-lg hover:text-primary-500" id="home-facility-icon" onClick={() => { - if (user?.home_facility_object) { - // has previous home facility - setReplaceHomeFacility({ - show: true, - userName: username, - previousFacility: - user?.home_facility_object, - newFacility: facility, - }); + if ( + ["DistrictAdmin", "StateAdmin"].includes( + authUser.user_type, + ) + ) { + if (user?.home_facility_object) { + // has previous home facility + setReplaceHomeFacility({ + show: true, + userName: username, + previousFacility: + user?.home_facility_object, + newFacility: facility, + }); + } else { + // no previous home facility + updateHomeFacility(username, facility); + } } else { - // no previous home facility - updateHomeFacility(username, facility); + Notification.Error({ + msg: "You don't have permission to perform this action. Please contact the admin", + }); } }} > @@ -832,14 +847,24 @@ function UserFacilities(props: { user: any }) {
); - } + }, )} {totalCount > limit && ( @@ -892,7 +917,7 @@ function UserFacilities(props: { user: any }) { handleOk={() => { updateHomeFacility( replaceHomeFacility.userName, - replaceHomeFacility.newFacility + replaceHomeFacility.newFacility, ); setReplaceHomeFacility({ show: false, From 98a4d69e24540c36a2b8b00cb4627969f15cf220 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Tue, 7 May 2024 20:07:43 +0530 Subject: [PATCH 2/5] fix merge conflicts --- src/Components/Users/ManageUsers.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index 2f37408de04..6ec71cda784 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -765,6 +765,14 @@ export function UserFacilities(props: { user: any }) {
{user?.home_facility_object?.name} + + + Home Facility + {["DistrictAdmin", "StateAdmin"].includes( authUser.user_type, ) && ( From d4983535e813e629b813badc104aa900798e75b2 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Wed, 8 May 2024 19:16:57 +0530 Subject: [PATCH 3/5] hide all buttons --- src/Components/Users/ManageUsers.tsx | 72 +++++++++++----------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index 06cbdb9f168..a2c87a9ac30 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -822,16 +822,14 @@ export function UserFacilities(props: { user: any }) { >
{facility.name} -
- - + -
+ }} + > + + + Unlink Facility + + +
+ )}
); From c5f4b673453cca0790f1306733b02884ae8b33c0 Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Sun, 26 May 2024 00:36:49 +0530 Subject: [PATCH 4/5] update privilage for nurse --- src/Components/Users/ManageUsers.tsx | 128 ++++++++++++++------------- 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index a2c87a9ac30..d9ffe01038f 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -777,26 +777,27 @@ export function UserFacilities(props: { user: any }) { {["DistrictAdmin", "StateAdmin"].includes( authUser.user_type, - ) && ( -
- -
- )} + ) || + (username === authUser.username && ( +
+ +
+ ))} @@ -824,51 +825,54 @@ export function UserFacilities(props: { user: any }) { {facility.name} {["DistrictAdmin", "StateAdmin"].includes( authUser.user_type, - ) && ( -
- + )} + - -
- )} + }} + > + + + Unlink Facility + + + + ))} ); From fa1942b380bf3815f83c28a25d673166293210dc Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Tue, 28 May 2024 13:15:31 +0530 Subject: [PATCH 5/5] fix typo in logic --- src/Components/Users/ManageUsers.tsx | 124 +++++++++++++-------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/Components/Users/ManageUsers.tsx b/src/Components/Users/ManageUsers.tsx index d9ffe01038f..cc52f4c08bc 100644 --- a/src/Components/Users/ManageUsers.tsx +++ b/src/Components/Users/ManageUsers.tsx @@ -775,29 +775,29 @@ export function UserFacilities(props: { user: any }) { Home Facility - {["DistrictAdmin", "StateAdmin"].includes( + {(["DistrictAdmin", "StateAdmin"].includes( authUser.user_type, ) || - (username === authUser.username && ( -
- -
- ))} + username === authUser.username) && ( +
+ +
+ )} @@ -823,56 +823,56 @@ export function UserFacilities(props: { user: any }) { >
{facility.name} - {["DistrictAdmin", "StateAdmin"].includes( + {(["DistrictAdmin", "StateAdmin"].includes( authUser.user_type, ) || - (username === authUser.username && ( -
- {authUser.user_type !== "Nurse" && ( - - )} + username === authUser.username) && ( +
+ {authUser.user_type !== "Nurse" && ( -
- ))} + )} + +
+ )}
);