diff --git a/src/components/Employee/EmpDashboard.jsx b/src/components/Employee/EmpDashboard.jsx index fee8ea3d..e3866cab 100644 --- a/src/components/Employee/EmpDashboard.jsx +++ b/src/components/Employee/EmpDashboard.jsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from "react"; import EmpOverview from "./EmpOverview"; import { useProjectsAllocationByEmployee } from "../../hooks/useProjects"; +import EmpReportingManager from "./EmpReportingManager"; const EmpDashboard = ({ profile }) => { const { @@ -16,6 +17,7 @@ const EmpDashboard = ({ profile }) => { {" "} +
@@ -80,6 +82,10 @@ const EmpDashboard = ({ profile }) => {
+
+ {" "} + +
); diff --git a/src/components/Employee/EmpReportingManager.jsx b/src/components/Employee/EmpReportingManager.jsx new file mode 100644 index 00000000..e5d96a03 --- /dev/null +++ b/src/components/Employee/EmpReportingManager.jsx @@ -0,0 +1,85 @@ +import React, { useState } from "react"; +import { useOrganizationHierarchy } from "../../hooks/useEmployees"; +import GlobalModel from "../common/GlobalModel"; +import ManageReporting from "./ManageReporting"; + +const EmpReportingManager = ({ employeeId }) => { + const { data, isLoading } = useOrganizationHierarchy(employeeId); + const [showManageReportingModal, setShowManageReportingModal] = useState(false); + + if (isLoading) return Loading...; + + const primary = data?.find((item) => item.isPrimary); + const secondary = data?.filter((item) => !item.isPrimary); + + // Create comma-separated string for secondary managers + const secondaryNames = secondary + ?.map((item) => `${item.reportTo?.firstName || ""} ${item.reportTo?.lastName || ""}`.trim()) + .join(", "); + + return ( +
+
+
+
+ + Reporting Manager + + + {/* Primary Reporting Manager */} +
+ + + Primary Reporting Manager + + : + + {primary?.reportTo?.firstName || NA}{" "} + {primary?.reportTo?.lastName || ""} + +
+ + {/* Secondary Reporting Manager (comma-separated) */} + {secondary?.length > 0 && ( +
+ + + Secondary Reporting Manager + + : + + {secondaryNames || NA} + +
+ )} + + {/* Open Modal Button */} +
+ +
+
+
+
+ + {/* ManageReporting Modal */} + {showManageReportingModal && ( + setShowManageReportingModal(false)} + > + setShowManageReportingModal(false)} + /> + + )} +
+ ); +}; + +export default EmpReportingManager;