From 4044f886dedbe0858702d099bc6192c4a48de39f Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Sat, 30 Dec 2023 17:26:08 +0530 Subject: [PATCH 1/3] Hide delete facility option for users who dont have access --- src/Components/Facility/FacilityHome.tsx | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index 2341d231675..af21ed512c3 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -99,6 +99,10 @@ export const FacilityHome = (props: any) => { USER_TYPES.findIndex((type) => type == authUser.user_type) >= StaffUserTypeIndex; + const hasPermissionToDeleteFacility = + authUser.user_type === "DistrictAdmin" || + authUser.user_type === "StateAdmin"; + const editCoverImageTooltip = hasPermissionToEditCoverImage && (
@@ -372,16 +376,18 @@ export const FacilityHome = (props: any) => { > View Users - setOpenDeleteDialog(true)} - className="flex items-center gap-3" - icon={} - authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])} - > - Delete Facility - + {hasPermissionToDeleteFacility && ( + setOpenDeleteDialog(true)} + className="flex items-center gap-3" + icon={} + authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])} + > + Delete Facility + + )}
From 17aeabcc634131b0483b8d5f249ae3982f10a2ca Mon Sep 17 00:00:00 2001 From: Pranshu Aggarwal <70687348+Pranshu1902@users.noreply.github.com> Date: Mon, 1 Jan 2024 16:43:13 +0530 Subject: [PATCH 2/3] refactor Co-authored-by: Rithvik Nishad --- src/Components/Facility/FacilityHome.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index af21ed512c3..b7dc46830e7 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -383,7 +383,6 @@ export const FacilityHome = (props: any) => { onClick={() => setOpenDeleteDialog(true)} className="flex items-center gap-3" icon={} - authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])} > Delete Facility From ad3a27bc7a962b7f00919f24feee5ed15c5040fd Mon Sep 17 00:00:00 2001 From: Pranshu1902 Date: Mon, 1 Jan 2024 22:57:07 +0530 Subject: [PATCH 3/3] fix lint and cypress tests --- cypress/e2e/patient_spec/patient_crud.cy.ts | 2 +- src/Components/Facility/FacilityHome.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 06a27333b9e..66c8b35e236 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -8,7 +8,7 @@ import { emergency_phone_number, phone_number, } from "../../pageobject/constants"; -const yearOfBirth = "2023"; +const yearOfBirth = "2001"; const calculateAge = () => { const currentYear = new Date().getFullYear(); diff --git a/src/Components/Facility/FacilityHome.tsx b/src/Components/Facility/FacilityHome.tsx index b7dc46830e7..52a7cd24027 100644 --- a/src/Components/Facility/FacilityHome.tsx +++ b/src/Components/Facility/FacilityHome.tsx @@ -1,6 +1,6 @@ import * as Notification from "../../Utils/Notifications.js"; -import AuthorizeFor, { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; +import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; import { FacilityModel } from "./models"; import { FACILITY_FEATURE_TYPES, USER_TYPES } from "../../Common/constants"; import DropdownMenu, { DropdownItem } from "../Common/components/Menu";