hide project infra, setting, Organization, and show only all employees and inactive employee
This commit is contained in:
parent
4ddb8415cc
commit
4ea1e06a9c
@ -253,7 +253,7 @@ const Header = () => {
|
|||||||
onClick={()=>openModal(null)}
|
onClick={()=>openModal(null)}
|
||||||
>
|
>
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
<span className="d-none d-md-inline-block">Add New Project</span>
|
<span className="d-none d-md-inline-block">Create Project</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li className="nav-item navbar-dropdown dropdown-user dropdown">
|
<li className="nav-item navbar-dropdown dropdown-user dropdown">
|
||||||
|
@ -27,13 +27,13 @@ const ProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
|
|
||||||
const ProjectTab = [
|
const ProjectTab = [
|
||||||
{ key: "profile", icon: "bx bx-user", label: "Profile" },
|
{ key: "profile", icon: "bx bx-user", label: "Profile" },
|
||||||
{ key: "teams", icon: "bx bx-group", label: "Teams" },
|
// { key: "teams", icon: "bx bx-group", label: "Teams" },
|
||||||
{
|
// {
|
||||||
key: "infra",
|
// key: "infra",
|
||||||
icon: "bx bx-grid-alt",
|
// icon: "bx bx-grid-alt",
|
||||||
label: "Infrastructure",
|
// label: "Infrastructure",
|
||||||
hidden: !(HasViewInfraStructure || HasManageInfra || HasManageTask),
|
// hidden: !(HasViewInfraStructure || HasManageInfra || HasManageTask),
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
key: "directory",
|
key: "directory",
|
||||||
icon: "bx bxs-contact",
|
icon: "bx bxs-contact",
|
||||||
@ -41,8 +41,8 @@ const ProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
hidden: !(DirAdmin || DireManager || DirUser),
|
hidden: !(DirAdmin || DireManager || DirUser),
|
||||||
},
|
},
|
||||||
{ key: "documents", icon: "bx bx-folder-open", label: "Documents",hidden:!(isViewDocuments || isModifyDocument || isUploadDocument) },
|
{ key: "documents", icon: "bx bx-folder-open", label: "Documents",hidden:!(isViewDocuments || isModifyDocument || isUploadDocument) },
|
||||||
{ key: "organization", icon: "bx bx-buildings", label: "Organization"},
|
// { key: "organization", icon: "bx bx-buildings", label: "Organization"},
|
||||||
{ key: "setting", icon: "bx bxs-cog", label: "Setting",hidden:!isManageTeam },
|
// { key: "setting", icon: "bx bxs-cog", label: "Setting",hidden:!isManageTeam },
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<div className="nav-align-top">
|
<div className="nav-align-top">
|
||||||
|
@ -14,7 +14,6 @@ export const useProjectAccess = (projectId) => {
|
|||||||
const canView = useHasUserPermission(VIEW_PROJECTS);
|
const canView = useHasUserPermission(VIEW_PROJECTS);
|
||||||
|
|
||||||
const loading = isLoading || !isFetched;
|
const loading = isLoading || !isFetched;
|
||||||
debugger
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (projectId && !loading && !canView) {
|
if (projectId && !loading && !canView) {
|
||||||
showToast("You don't have permission to view project details", "warning");
|
showToast("You don't have permission to view project details", "warning");
|
||||||
|
@ -36,31 +36,30 @@ import GlobalModel from "../../components/common/GlobalModel";
|
|||||||
import usePagination from "../../hooks/usePagination";
|
import usePagination from "../../hooks/usePagination";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
import Pagination from "../../components/common/Pagination";
|
||||||
|
|
||||||
const EmployeeList = () => {
|
const EmployeeList = () => {
|
||||||
const selectedProjectId = useSelector(
|
// const selectedProjectId = useSelector(
|
||||||
(store) => store.localVariables.projectId
|
// (store) => store.localVariables.projectId
|
||||||
);
|
// );
|
||||||
const { projectNames, loading: projectLoading, fetchData } = useProjectName();
|
// const { projectNames, loading: projectLoading, fetchData } = useProjectName();
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const [showInactive, setShowInactive] = useState(false);
|
const [showInactive, setShowInactive] = useState(false);
|
||||||
const [showAllEmployees, setShowAllEmployees] = useState(false);
|
const [showAllEmployees, setShowAllEmployees] = useState(true);
|
||||||
const Manage_Employee = useHasUserPermission(MANAGE_EMPLOYEES);
|
const Manage_Employee = useHasUserPermission(MANAGE_EMPLOYEES);
|
||||||
|
|
||||||
const { employees, loading, setLoading, error, recallEmployeeData } =
|
const { employees, loading, setLoading, error, recallEmployeeData } =
|
||||||
useEmployeesAllOrByProjectId(
|
useEmployeesAllOrByProjectId(
|
||||||
showAllEmployees,
|
showAllEmployees,
|
||||||
selectedProjectId,
|
null,
|
||||||
showInactive
|
showInactive
|
||||||
);
|
);
|
||||||
|
|
||||||
const [employeeList, setEmployeeList] = useState([]);
|
const [employeeList, setEmployeeList] = useState([]);
|
||||||
const [modelConfig, setModelConfig] = useState();
|
const [modelConfig, setModelConfig] = useState();
|
||||||
const [EmpForManageRole, setEmpForManageRole] = useState(null);
|
const [EmpForManageRole, setEmpForManageRole] = useState(null);
|
||||||
// const [currentPage, setCurrentPage] = useState(1);
|
|
||||||
// const [itemsPerPage] = useState(ITEMS_PER_PAGE);
|
|
||||||
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
||||||
const [searchText, setSearchText] = useState("");
|
const [searchText, setSearchText] = useState("");
|
||||||
const [filteredData, setFilteredData] = useState([]);
|
const [filteredData, setFilteredData] = useState([]);
|
||||||
@ -78,11 +77,11 @@ const EmployeeList = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (selectedProjectId === null) {
|
// if (selectedProjectId === null) {
|
||||||
dispatch(setProjectId(projectNames[0]?.id));
|
// dispatch(setProjectId(projectNames[0]?.id));
|
||||||
}
|
// }
|
||||||
}, [selectedProjectId]);
|
// }, [selectedProjectId]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const applySearchFilter = (data, text) => {
|
const applySearchFilter = (data, text) => {
|
||||||
@ -205,13 +204,9 @@ const EmployeeList = () => {
|
|||||||
|
|
||||||
setCurrentPage((prevPage) => (prevPage !== 1 ? 1 : prevPage));
|
setCurrentPage((prevPage) => (prevPage !== 1 ? 1 : prevPage));
|
||||||
}
|
}
|
||||||
}, [loading, employees, selectedProjectId, showAllEmployees]);
|
}, [loading, employees, showAllEmployees]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!showAllEmployees) {
|
|
||||||
recallEmployeeData(showInactive, selectedProjectId);
|
|
||||||
}
|
|
||||||
}, [selectedProjectId, showInactive, showAllEmployees, recallEmployeeData]);
|
|
||||||
|
|
||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
@ -219,11 +214,12 @@ const EmployeeList = () => {
|
|||||||
setEmployeeList([]);
|
setEmployeeList([]);
|
||||||
recallEmployeeData(
|
recallEmployeeData(
|
||||||
showInactive,
|
showInactive,
|
||||||
showAllEmployees ? null : selectedProjectId
|
null,
|
||||||
); // Use selectedProjectId here
|
showAllEmployees
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[employees, showInactive, showAllEmployees, selectedProjectId] // Add all relevant dependencies
|
[employees, showInactive, showAllEmployees]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -304,7 +300,7 @@ const EmployeeList = () => {
|
|||||||
{/* Switches: All Employees + Inactive */}
|
{/* Switches: All Employees + Inactive */}
|
||||||
<div className="d-flex flex-wrap align-items-center gap-3">
|
<div className="d-flex flex-wrap align-items-center gap-3">
|
||||||
{/* All Employees Switch */}
|
{/* All Employees Switch */}
|
||||||
{ViewAllEmployee && (
|
{/* {ViewAllEmployee && (
|
||||||
<div className="form-check form-switch text-start">
|
<div className="form-check form-switch text-start">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
@ -321,27 +317,27 @@ const EmployeeList = () => {
|
|||||||
Show All Employees
|
Show All Employees
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
{/* Show Inactive Employees Switch */}
|
{/* Show Inactive Employees Switch */}
|
||||||
{showAllEmployees && (
|
{/* {showAllEmployees && ( */}
|
||||||
<div className="form-check form-switch text-start">
|
<div className="form-check form-switch text-start">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
role="switch"
|
role="switch"
|
||||||
id="inactiveEmployeesCheckbox"
|
id="inactiveEmployeesCheckbox"
|
||||||
checked={showInactive}
|
checked={showInactive}
|
||||||
onChange={(e) => setShowInactive(e.target.checked)}
|
onChange={(e) => setShowInactive(e.target.checked)}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
className="form-check-label ms-0"
|
className="form-check-label ms-0"
|
||||||
htmlFor="inactiveEmployeesCheckbox"
|
htmlFor="inactiveEmployeesCheckbox"
|
||||||
>
|
>
|
||||||
Show Inactive Employees
|
Show Inactive Employees
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
)}
|
{/* )} */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right side: Search + Export + Add Employee */}
|
{/* Right side: Search + Export + Add Employee */}
|
||||||
@ -697,55 +693,12 @@ const EmployeeList = () => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div style={{ width: "1%" }}></div>
|
{displayData.length > 0 && (
|
||||||
|
<Pagination
|
||||||
{/* Pagination */}
|
currentPage={currentPage}
|
||||||
{!loading && displayData.length > ITEMS_PER_PAGE && (
|
totalPages={totalPages}
|
||||||
<nav aria-label="Page">
|
onPageChange={paginate}
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1">
|
/>
|
||||||
<li
|
|
||||||
className={`page-item ${
|
|
||||||
currentPage === 1 ? "disabled" : ""
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
className="page-link btn-xs"
|
|
||||||
onClick={() => paginate(currentPage - 1)}
|
|
||||||
>
|
|
||||||
«
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{[...Array(totalPages)]?.map((_, index) => (
|
|
||||||
<li
|
|
||||||
key={index}
|
|
||||||
className={`page-item ${
|
|
||||||
currentPage === index + 1 ? "active" : ""
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
className="page-link"
|
|
||||||
onClick={() => paginate(index + 1)}
|
|
||||||
>
|
|
||||||
{index + 1}
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
|
|
||||||
<li
|
|
||||||
className={`page-item ${
|
|
||||||
currentPage === totalPages ? "disabled" : ""
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
className="page-link"
|
|
||||||
onClick={() => paginate(currentPage + 1)}
|
|
||||||
>
|
|
||||||
»
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -20,7 +20,7 @@ import { setProjectId } from "../../slices/localVariablesSlice";
|
|||||||
import ProjectDocuments from "../../components/Project/ProjectDocuments";
|
import ProjectDocuments from "../../components/Project/ProjectDocuments";
|
||||||
import ProjectSetting from "../../components/Project/ProjectSetting";
|
import ProjectSetting from "../../components/Project/ProjectSetting";
|
||||||
import DirectoryPage from "../Directory/DirectoryPage";
|
import DirectoryPage from "../Directory/DirectoryPage";
|
||||||
import { useProjectAccess } from "../../hooks/useProjectAccess";
|
import { useProjectAccess } from "../../hooks/useProjectAccess";
|
||||||
|
|
||||||
import "./ProjectDetails.css";
|
import "./ProjectDetails.css";
|
||||||
import ProjectOrganizations from "../../components/Project/ProjectOrganizations";
|
import ProjectOrganizations from "../../components/Project/ProjectOrganizations";
|
||||||
@ -30,8 +30,11 @@ const ProjectDetails = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const { projectNames } = useProjectName();
|
const { projectNames } = useProjectName();
|
||||||
const { projects_Details, loading: projectLoading, refetch } =
|
const {
|
||||||
useProjectDetails(projectId);
|
projects_Details,
|
||||||
|
loading: projectLoading,
|
||||||
|
refetch,
|
||||||
|
} = useProjectDetails(projectId);
|
||||||
|
|
||||||
const { canView, loading: permsLoading } = useProjectAccess(projectId);
|
const { canView, loading: permsLoading } = useProjectAccess(projectId);
|
||||||
|
|
||||||
@ -47,7 +50,10 @@ const ProjectDetails = () => {
|
|||||||
|
|
||||||
const handler = useCallback(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
if (msg.keyword === "Update_Project" && projects_Details?.id === msg.response.id) {
|
if (
|
||||||
|
msg.keyword === "Update_Project" &&
|
||||||
|
projects_Details?.id === msg.response.id
|
||||||
|
) {
|
||||||
refetch();
|
refetch();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -75,13 +81,10 @@ const ProjectDetails = () => {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-lg-4 col-md-5 mt-2">
|
<div className="col-lg-4 col-md-5 mt-2">
|
||||||
<AboutProject />
|
<AboutProject />
|
||||||
<ProjectOverview project={projectId} />
|
{/* <ProjectOverview project={projectId} /> */}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-lg-8 col-md-7 mt-5">
|
<div className="col-lg-8 col-md-7 mt-2">
|
||||||
<ProjectProgressChart ShowAllProject="false" DefaultRange="1M" />
|
<AttendanceOverview />
|
||||||
<div className="mt-5">
|
|
||||||
<AttendanceOverview />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -4,6 +4,7 @@ import axiosRetry from "axios-retry";
|
|||||||
import showToast from "../services/toastService";
|
import showToast from "../services/toastService";
|
||||||
import { startSignalR, stopSignalR } from "../services/signalRService";
|
import { startSignalR, stopSignalR } from "../services/signalRService";
|
||||||
import { BASE_URL } from "./constants";
|
import { BASE_URL } from "./constants";
|
||||||
|
import { removeSession } from "./authUtils";
|
||||||
const base_Url = BASE_URL;
|
const base_Url = BASE_URL;
|
||||||
|
|
||||||
export const axiosClient = axios.create({
|
export const axiosClient = axios.create({
|
||||||
@ -77,8 +78,10 @@ axiosClient.interceptors.response.use(
|
|||||||
if (
|
if (
|
||||||
!refreshToken ||
|
!refreshToken ||
|
||||||
error.response.data?.errors === "Invalid or expired refresh token."
|
error.response.data?.errors === "Invalid or expired refresh token."
|
||||||
|
|
||||||
) {
|
) {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
|
removeSession()
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +110,7 @@ axiosClient.interceptors.response.use(
|
|||||||
originalRequest.headers["Authorization"] = `Bearer ${token}`;
|
originalRequest.headers["Authorization"] = `Bearer ${token}`;
|
||||||
return axiosClient(originalRequest);
|
return axiosClient(originalRequest);
|
||||||
} catch (refreshError) {
|
} catch (refreshError) {
|
||||||
|
removeSession()
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
return Promise.reject(refreshError);
|
return Promise.reject(refreshError);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user