From afe32eb49d628a0486e0253c55b689b5edca2dbb Mon Sep 17 00:00:00 2001 From: Umesh Desai Date: Tue, 10 Jun 2025 12:39:34 +0530 Subject: [PATCH 1/3] Adding Change Password button on Employee Profile Page. --- src/pages/employee/EmployeeProfile.jsx | 325 +++++++++++++------------ 1 file changed, 167 insertions(+), 158 deletions(-) diff --git a/src/pages/employee/EmployeeProfile.jsx b/src/pages/employee/EmployeeProfile.jsx index 4de20675..a4ad6aba 100644 --- a/src/pages/employee/EmployeeProfile.jsx +++ b/src/pages/employee/EmployeeProfile.jsx @@ -17,6 +17,8 @@ import { useNavigate } from "react-router-dom"; import Avatar from "../../components/common/Avatar"; import AttendancesEmployeeRecords from "./AttendancesEmployeeRecords"; import ManageEmployee from "../../components/Employee/ManageEmployee"; +import { useChangePassword } from "../../components/Context/ChangePasswordContext"; + const EmployeeProfile = () => { const projectID = useSelector((store) => store.localVariables.projectId); const { employeeId } = useParams(); @@ -27,17 +29,17 @@ const EmployeeProfile = () => { const tab = SearchParams.get("for"); const [activePill, setActivePill] = useState(tab); const [currentEmployee, setCurrentEmployee] = useState(); - const [showModal, setShowModal] = useState(false); + const [showModal, setShowModal] = useState(false); const handlePillClick = (pillKey) => { setActivePill(pillKey); }; - const closeModal = () => { - setShowModal(false); - fetchEmployeeProfile(employeeId); - }; - const handleShow = () => setShowModal(true); + const closeModal = () => { + setShowModal(false); + fetchEmployeeProfile(employeeId); + }; + const handleShow = () => setShowModal(true); const fetchEmployeeProfile = async (employeeID) => { try { @@ -95,177 +97,184 @@ const EmployeeProfile = () => { if (loading) { return
Loading...
; } - +const { openChangePassword } = useChangePassword(); return ( <> {showModal && (
-
-
- -
+ className={`modal fade ${showModal ? "show" : ""} `} + tabIndex="-1" + role="dialog" + style={{ display: showModal ? "block" : "none" }} + aria-hidden={!showModal} + > +
+
+
-
)} +
+
)} -
- +
+ -
-
-
-
-
-
-
-
- -
-

{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}

+
+
+
+
+
+
+
+
+ +
+

{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}

+
-
-
-
-
- Employee Info -
- - - - - - - - - - - - - - - - - - +
+
+
+ Employee Info +
+
Email: - {currentEmployee?.email || NA} -
- Phone Number: - - {currentEmployee?.phoneNumber || NA} -
- Emergency Contact Person: - - {currentEmployee?.emergencyContactPerson || ( - NA - )} -
- Emergency Contact Number: - - {currentEmployee?.emergencyPhoneNumber || ( - NA - )} -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Email: + {currentEmployee?.email || NA} +
+ Phone Number: + + {currentEmployee?.phoneNumber || NA} +
+ Emergency Contact Person: + + {currentEmployee?.emergencyContactPerson || ( + NA + )} +
+ Emergency Contact Number: + + {currentEmployee?.emergencyPhoneNumber || ( + NA + )} +
Gender: + {currentEmployee?.gender || NA} +
+ Birth Date: + + {currentEmployee?.birthDate ? ( + new Date( + currentEmployee.birthDate + ).toLocaleDateString() + ) : ( + NA + )} +
+ Joining Date: + + {currentEmployee?.joiningDate ? ( + new Date( + currentEmployee.joiningDate + ).toLocaleDateString() + ) : ( + NA + )} +
+ Job Role: + + {currentEmployee?.jobRole || NA} +
Address: + {currentEmployee?.currentAddress || NA} +
+
+ + + - - Gender: - - {currentEmployee?.gender || NA} - - - - - Birth Date: - - - {currentEmployee?.birthDate ? ( - new Date( - currentEmployee.birthDate - ).toLocaleDateString() - ) : ( - NA - )} - - - - - Joining Date: - - - {currentEmployee?.joiningDate ? ( - new Date( - currentEmployee.joiningDate - ).toLocaleDateString() - ) : ( - NA - )} - - - - - Job Role: - - - {currentEmployee?.jobRole || NA} - - - - Address: - - {currentEmployee?.currentAddress || NA} - - - -
-
-
-
-
- -
-
-
{renderContent()}
+
+
+ +
+
+
{renderContent()}
+
-
); -- 2.43.0 From 69679db1be5e002b0813daefdf505d79cb88b0ca Mon Sep 17 00:00:00 2001 From: Vikas Nale Date: Tue, 10 Jun 2025 20:07:06 +0530 Subject: [PATCH 2/3] show change password button to self only --- src/pages/employee/EmployeeProfile.jsx | 70 ++++++++++++++------------ 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/pages/employee/EmployeeProfile.jsx b/src/pages/employee/EmployeeProfile.jsx index a4ad6aba..dfa88241 100644 --- a/src/pages/employee/EmployeeProfile.jsx +++ b/src/pages/employee/EmployeeProfile.jsx @@ -10,6 +10,8 @@ import { useEmployees, useEmployeesByProject, } from "../../hooks/useEmployees"; +import { useProfile } from "../../hooks/useProfile"; + import { useSelector } from "react-redux"; import EmployeeRepository from "../../repositories/EmployeeRepository"; import { ComingSoonPage } from "../Misc/ComingSoonPage"; @@ -20,6 +22,8 @@ import ManageEmployee from "../../components/Employee/ManageEmployee"; import { useChangePassword } from "../../components/Context/ChangePasswordContext"; const EmployeeProfile = () => { + const { profile } = useProfile(); + const projectID = useSelector((store) => store.localVariables.projectId); const { employeeId } = useParams(); // const {employee,loading} = useEmployeeProfile(employeeId) @@ -97,28 +101,28 @@ const EmployeeProfile = () => { if (loading) { return
Loading...
; } -const { openChangePassword } = useChangePassword(); + const { openChangePassword } = useChangePassword(); return ( - <> {showModal && (
-
+ <> + {" "} + {showModal && (
- +
+
+ +
+
-
-
)} - + )}
- Gender: + + Gender: + {currentEmployee?.gender || NA} @@ -231,9 +237,13 @@ const { openChangePassword } = useChangePassword(); - Address: + + Address: + - {currentEmployee?.currentAddress || NA} + {currentEmployee?.currentAddress || ( + NA + )} @@ -245,15 +255,14 @@ const { openChangePassword } = useChangePassword(); > Edit Profile - - - - + {currentEmployee?.id == profile?.employeeInfo?.id && ( + + )}
@@ -276,7 +285,6 @@ const { openChangePassword } = useChangePassword();
- ); }; -- 2.43.0 From 070df90f7be43a70702f8b10945ccb4bda473923 Mon Sep 17 00:00:00 2001 From: Vikas Nale Date: Tue, 10 Jun 2025 20:09:50 +0530 Subject: [PATCH 3/3] change password label change --- src/pages/authentication/ChangePassword.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/authentication/ChangePassword.jsx b/src/pages/authentication/ChangePassword.jsx index a0b7cebd..753340e4 100644 --- a/src/pages/authentication/ChangePassword.jsx +++ b/src/pages/authentication/ChangePassword.jsx @@ -212,15 +212,16 @@ const ChangePasswordPage = ({ onClose }) => {

Password must be:

- at least 8 characters long

- - must contain at least one uppercase letter + - must contain one uppercase, one lowercase letter, at least one + number, at least one special character

-

+ {/*

- must contain at least one lowercase letter

- must contain at least one number

- must contain at least one special character -

+

*/}
-- 2.43.0