Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide delete facility option for users who dont have access #6953

Merged
merged 5 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
27 changes: 16 additions & 11 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 && (
<div className="absolute right-0 top-0 z-10 flex h-full w-full flex-col items-center justify-center bg-black text-sm text-gray-300 opacity-0 transition-[opacity] hover:opacity-60 md:h-[88px]">
<i className="fa-solid fa-pen" />
Expand Down Expand Up @@ -372,16 +376,17 @@ export const FacilityHome = (props: any) => {
>
View Users
</DropdownItem>
<DropdownItem
id="delete-facility"
variant="danger"
onClick={() => setOpenDeleteDialog(true)}
className="flex items-center gap-3"
icon={<CareIcon className="care-l-trash-alt text-lg" />}
authorizeFor={AuthorizeFor(["DistrictAdmin", "StateAdmin"])}
>
Delete Facility
</DropdownItem>
{hasPermissionToDeleteFacility && (
<DropdownItem
id="delete-facility"
variant="danger"
onClick={() => setOpenDeleteDialog(true)}
className="flex items-center gap-3"
icon={<CareIcon className="care-l-trash-alt text-lg" />}
>
Delete Facility
</DropdownItem>
)}
</DropdownMenu>
</div>
<div className="flex flex-col justify-end">
Expand Down
Loading