diff --git a/src/pages/employee/EmployeeList.jsx b/src/pages/employee/EmployeeList.jsx index ef470979..002d77d4 100644 --- a/src/pages/employee/EmployeeList.jsx +++ b/src/pages/employee/EmployeeList.jsx @@ -9,7 +9,7 @@ import { useEmployeesAllOrByProjectId, useSuspendEmployee } from "../../hooks/us import { useProjects } from "../../hooks/useProjects"; import { useProfile } from "../../hooks/useProfile"; import { hasUserPermission } from "../../utils/authUtils"; -import { ITEMS_PER_PAGE, MANAGE_EMPLOYEES } from "../../utils/constants"; +import { ITEMS_PER_PAGE, MANAGE_EMPLOYEES, VIEW_ALL_EMPLOYEES, VIEW_TEAM_MEMBERS } from "../../utils/constants"; import { clearCacheKey } from "../../slices/apiDataManager"; import { useHasUserPermission } from "../../hooks/useHasUserPermission"; import SuspendEmp from "../../components/Employee/SuspendEmp"; // Keep if you use SuspendEmp @@ -56,6 +56,8 @@ const EmployeeList = () => { const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [selectedEmpFordelete, setSelectedEmpFordelete] = useState(null); const [ employeeLodaing, setemployeeLodaing ] = useState( false ); + const ViewTeamMember = useHasUserPermission(VIEW_TEAM_MEMBERS) + const ViewAllEmployee = useHasUserPermission(VIEW_ALL_EMPLOYEES) const { mutate: suspendEmployee, isPending: empLodaing @@ -120,23 +122,6 @@ useEffect(() => { setIsCreateModalOpen(true); }; - // const closeModal = () => { - // setIsCreateModalOpen(false); - - // const modalElement = document.getElementById("managerole-modal"); - // if (modalElement && !showModal) { - // modalElement.classList.remove("show"); - // modalElement.style.display = "none"; - // document.body.classList.remove("modal-open"); - // document.querySelector(".modal-backdrop")?.remove(); - // } - // setShowModal(false); - // clearCacheKey("employeeProfile"); - // recallEmployeeData(showInactive, showAllEmployees ? null : selectedProjectId); // Use selectedProjectId here - // }; - // const handleShow = () => setShowModal(true); - // const handleClose = () => setShowModal( false ); - useEffect(() => { if (!loading && Array.isArray(employees)) { const sorted = [...employees].sort((a, b) => { @@ -296,7 +281,9 @@ const handleAllEmployeesToggle = (e) => { { label: "Employees", link: null }, ]} > -
+ + + {ViewTeamMember ? (
@@ -309,6 +296,7 @@ const handleAllEmployeesToggle = (e) => { {/* Switches: All Employees + Inactive */}
{/* All Employees Switch */} + {ViewAllEmployee && (
{ All Employees
+ ) } {/* Show Inactive Employees Switch */} {showAllEmployees && ( @@ -702,7 +691,14 @@ const handleAllEmployeesToggle = (e) => {
-
+
):( +
+
+ +

Access Denied: You don't have permission to perform this action. !

+
+
+ )} ); diff --git a/src/utils/constants.jsx b/src/utils/constants.jsx index fca560af..f8d14a30 100644 --- a/src/utils/constants.jsx +++ b/src/utils/constants.jsx @@ -11,6 +11,11 @@ export const VIEW_PROJECTS = "6ea44136-987e-44ba-9e5d-1cf8f5837ebc" export const MANAGE_EMPLOYEES = "a97d366a-c2bb-448d-be93-402bd2324566" +export const VIEW_ALL_EMPLOYEES = "60611762-7f8a-4fb5-b53f-b1139918796b" + +export const VIEW_TEAM_MEMBERS = "b82d2b7e-0d52-45f3-997b-c008ea460e7f" + + export const MANAGE_PROJECT_INFRA = "cf2825ad-453b-46aa-91d9-27c124d63373" export const VIEW_PROJECT_INFRA = "8d7cc6e3-9147-41f7-aaa7-fa507e450bd4"