hide project infra, setting, Organization, and show only all employees and inactive employee

This commit is contained in:
pramod.mahajan 2025-09-30 18:16:29 +05:30
parent 4ddb8415cc
commit 4ea1e06a9c
6 changed files with 71 additions and 112 deletions

View File

@ -253,7 +253,7 @@ const Header = () => {
onClick={()=>openModal(null)}
>
<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>
</li>
<li className="nav-item navbar-dropdown dropdown-user dropdown">

View File

@ -27,13 +27,13 @@ const ProjectNav = ({ onPillClick, activePill }) => {
const ProjectTab = [
{ key: "profile", icon: "bx bx-user", label: "Profile" },
{ key: "teams", icon: "bx bx-group", label: "Teams" },
{
key: "infra",
icon: "bx bx-grid-alt",
label: "Infrastructure",
hidden: !(HasViewInfraStructure || HasManageInfra || HasManageTask),
},
// { key: "teams", icon: "bx bx-group", label: "Teams" },
// {
// key: "infra",
// icon: "bx bx-grid-alt",
// label: "Infrastructure",
// hidden: !(HasViewInfraStructure || HasManageInfra || HasManageTask),
// },
{
key: "directory",
icon: "bx bxs-contact",
@ -41,8 +41,8 @@ const ProjectNav = ({ onPillClick, activePill }) => {
hidden: !(DirAdmin || DireManager || DirUser),
},
{ key: "documents", icon: "bx bx-folder-open", label: "Documents",hidden:!(isViewDocuments || isModifyDocument || isUploadDocument) },
{ key: "organization", icon: "bx bx-buildings", label: "Organization"},
{ key: "setting", icon: "bx bxs-cog", label: "Setting",hidden:!isManageTeam },
// { key: "organization", icon: "bx bx-buildings", label: "Organization"},
// { key: "setting", icon: "bx bxs-cog", label: "Setting",hidden:!isManageTeam },
];
return (
<div className="nav-align-top">

View File

@ -14,7 +14,6 @@ export const useProjectAccess = (projectId) => {
const canView = useHasUserPermission(VIEW_PROJECTS);
const loading = isLoading || !isFetched;
debugger
useEffect(() => {
if (projectId && !loading && !canView) {
showToast("You don't have permission to view project details", "warning");

View File

@ -36,31 +36,30 @@ import GlobalModel from "../../components/common/GlobalModel";
import usePagination from "../../hooks/usePagination";
import { setProjectId } from "../../slices/localVariablesSlice";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
import Pagination from "../../components/common/Pagination";
const EmployeeList = () => {
const selectedProjectId = useSelector(
(store) => store.localVariables.projectId
);
const { projectNames, loading: projectLoading, fetchData } = useProjectName();
// const selectedProjectId = useSelector(
// (store) => store.localVariables.projectId
// );
// const { projectNames, loading: projectLoading, fetchData } = useProjectName();
const dispatch = useDispatch();
const [showInactive, setShowInactive] = useState(false);
const [showAllEmployees, setShowAllEmployees] = useState(false);
const [showAllEmployees, setShowAllEmployees] = useState(true);
const Manage_Employee = useHasUserPermission(MANAGE_EMPLOYEES);
const { employees, loading, setLoading, error, recallEmployeeData } =
useEmployeesAllOrByProjectId(
showAllEmployees,
selectedProjectId,
null,
showInactive
);
const [employeeList, setEmployeeList] = useState([]);
const [modelConfig, setModelConfig] = useState();
const [EmpForManageRole, setEmpForManageRole] = useState(null);
// const [currentPage, setCurrentPage] = useState(1);
// const [itemsPerPage] = useState(ITEMS_PER_PAGE);
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [searchText, setSearchText] = useState("");
const [filteredData, setFilteredData] = useState([]);
@ -78,11 +77,11 @@ const EmployeeList = () => {
}
);
useEffect(() => {
if (selectedProjectId === null) {
dispatch(setProjectId(projectNames[0]?.id));
}
}, [selectedProjectId]);
// useEffect(() => {
// if (selectedProjectId === null) {
// dispatch(setProjectId(projectNames[0]?.id));
// }
// }, [selectedProjectId]);
const navigate = useNavigate();
const applySearchFilter = (data, text) => {
@ -205,13 +204,9 @@ const EmployeeList = () => {
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(
(msg) => {
@ -219,11 +214,12 @@ const EmployeeList = () => {
setEmployeeList([]);
recallEmployeeData(
showInactive,
showAllEmployees ? null : selectedProjectId
); // Use selectedProjectId here
null,
showAllEmployees
);
}
},
[employees, showInactive, showAllEmployees, selectedProjectId] // Add all relevant dependencies
[employees, showInactive, showAllEmployees]
);
useEffect(() => {
@ -304,7 +300,7 @@ const EmployeeList = () => {
{/* Switches: All Employees + Inactive */}
<div className="d-flex flex-wrap align-items-center gap-3">
{/* All Employees Switch */}
{ViewAllEmployee && (
{/* {ViewAllEmployee && (
<div className="form-check form-switch text-start">
<input
type="checkbox"
@ -321,27 +317,27 @@ const EmployeeList = () => {
Show All Employees
</label>
</div>
)}
)} */}
{/* Show Inactive Employees Switch */}
{showAllEmployees && (
<div className="form-check form-switch text-start">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showInactive}
onChange={(e) => setShowInactive(e.target.checked)}
/>
<label
className="form-check-label ms-0"
htmlFor="inactiveEmployeesCheckbox"
>
Show Inactive Employees
</label>
</div>
)}
{/* {showAllEmployees && ( */}
<div className="form-check form-switch text-start">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showInactive}
onChange={(e) => setShowInactive(e.target.checked)}
/>
<label
className="form-check-label ms-0"
htmlFor="inactiveEmployeesCheckbox"
>
Show Inactive Employees
</label>
</div>
{/* )} */}
</div>
{/* Right side: Search + Export + Add Employee */}
@ -697,55 +693,12 @@ const EmployeeList = () => {
</tbody>
</table>
<div style={{ width: "1%" }}></div>
{/* Pagination */}
{!loading && displayData.length > ITEMS_PER_PAGE && (
<nav aria-label="Page">
<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)}
>
&laquo;
</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)}
>
&raquo;
</button>
</li>
</ul>
</nav>
{displayData.length > 0 && (
<Pagination
currentPage={currentPage}
totalPages={totalPages}
onPageChange={paginate}
/>
)}
</div>
</div>

View File

@ -20,7 +20,7 @@ import { setProjectId } from "../../slices/localVariablesSlice";
import ProjectDocuments from "../../components/Project/ProjectDocuments";
import ProjectSetting from "../../components/Project/ProjectSetting";
import DirectoryPage from "../Directory/DirectoryPage";
import { useProjectAccess } from "../../hooks/useProjectAccess";
import { useProjectAccess } from "../../hooks/useProjectAccess";
import "./ProjectDetails.css";
import ProjectOrganizations from "../../components/Project/ProjectOrganizations";
@ -30,8 +30,11 @@ const ProjectDetails = () => {
const dispatch = useDispatch();
const { projectNames } = useProjectName();
const { projects_Details, loading: projectLoading, refetch } =
useProjectDetails(projectId);
const {
projects_Details,
loading: projectLoading,
refetch,
} = useProjectDetails(projectId);
const { canView, loading: permsLoading } = useProjectAccess(projectId);
@ -47,7 +50,10 @@ const ProjectDetails = () => {
const handler = useCallback(
(msg) => {
if (msg.keyword === "Update_Project" && projects_Details?.id === msg.response.id) {
if (
msg.keyword === "Update_Project" &&
projects_Details?.id === msg.response.id
) {
refetch();
}
},
@ -75,13 +81,10 @@ const ProjectDetails = () => {
<div className="row">
<div className="col-lg-4 col-md-5 mt-2">
<AboutProject />
<ProjectOverview project={projectId} />
{/* <ProjectOverview project={projectId} /> */}
</div>
<div className="col-lg-8 col-md-7 mt-5">
<ProjectProgressChart ShowAllProject="false" DefaultRange="1M" />
<div className="mt-5">
<AttendanceOverview />
</div>
<div className="col-lg-8 col-md-7 mt-2">
<AttendanceOverview />
</div>
</div>
);

View File

@ -4,6 +4,7 @@ import axiosRetry from "axios-retry";
import showToast from "../services/toastService";
import { startSignalR, stopSignalR } from "../services/signalRService";
import { BASE_URL } from "./constants";
import { removeSession } from "./authUtils";
const base_Url = BASE_URL;
export const axiosClient = axios.create({
@ -77,8 +78,10 @@ axiosClient.interceptors.response.use(
if (
!refreshToken ||
error.response.data?.errors === "Invalid or expired refresh token."
) {
redirectToLogin();
removeSession()
return Promise.reject(error);
}
@ -107,6 +110,7 @@ axiosClient.interceptors.response.use(
originalRequest.headers["Authorization"] = `Bearer ${token}`;
return axiosClient(originalRequest);
} catch (refreshError) {
removeSession()
redirectToLogin();
return Promise.reject(refreshError);
}