-
diff --git a/src/components/common/Avatar.jsx b/src/components/common/Avatar.jsx
index 900c9403..537af159 100644
--- a/src/components/common/Avatar.jsx
+++ b/src/components/common/Avatar.jsx
@@ -1,6 +1,22 @@
-import React from "react";
+import React, { useState, useEffect } from "react";
+
+// A simple hash function to generate a deterministic value from the name
+function hashString(str) {
+ let hash = 0;
+ for (let i = 0; i < str.length; i++) {
+ const char = str.charCodeAt(i);
+ hash = (hash << 5) - hash + char;
+ }
+ return hash;
+}
const Avatar = ({ firstName, lastName, size='sm' }) => {
+ // Combine firstName and lastName to create a unique string for hashing
+ const fullName = `${firstName} ${lastName}`;
+
+ const [bgClass, setBgClass] = useState("");
+
+ // Function to generate the avatar text
function generateAvatarText(firstName, lastName) {
if (!firstName) return "";
if (!lastName || lastName.trim() === "") {
@@ -9,7 +25,8 @@ const Avatar = ({ firstName, lastName, size='sm' }) => {
return `${firstName[0]}${lastName[0]}`.toUpperCase();
}
- function getRandomBootstrapBgClass() {
+ // Function to map the hash value to a Bootstrap background class
+ function getBgClassFromHash(hash) {
const bgClasses = [
"bg-primary",
"bg-secondary",
@@ -21,21 +38,27 @@ const Avatar = ({ firstName, lastName, size='sm' }) => {
"text-light",
];
- const randomIndex = Math.floor(Math.random() * bgClasses.length);
- return bgClasses[randomIndex];
+ // Use the hash value to pick a background color from the array
+ const index = Math.abs(hash % bgClasses.length);
+ return bgClasses[index];
}
+
+ useEffect(() => {
+ // Generate the hash from the full name and map it to a background class
+ const hash = hashString(fullName);
+ setBgClass(getBgClassFromHash(hash));
+ }, [fullName]); // Re-run if the fullName changes
+
return (
- <>
-
-
-
- {generateAvatarText(firstName, lastName)}
-
-
+
+
+
+ {generateAvatarText(firstName, lastName)}
+
- >
+
);
};
diff --git a/src/pages/employee/EmployeeProfile.jsx b/src/pages/employee/EmployeeProfile.jsx
index a1e10df3..e53eeeb2 100644
--- a/src/pages/employee/EmployeeProfile.jsx
+++ b/src/pages/employee/EmployeeProfile.jsx
@@ -1,4 +1,4 @@
-import React,{useState,useEffect} from "react";
+import React, { useState, useEffect } from "react";
import EmpProfile from "../../components/Employee/EmpProfile";
import axios from "axios";
import Breadcrumb from "../../components/common/Breadcrumb";
@@ -9,7 +9,8 @@ import { useEmployeeProfile, useEmployees, useEmployeesByProject } from "../../h
import { useSelector } from "react-redux";
import EmployeeRepository from "../../repositories/EmployeeRepository";
import { ComingSoonPage } from "../Misc/ComingSoonPage";
-
+import { useNavigate } from "react-router-dom";
+import Avatar from "../../components/common/Avatar";
const EmployeeProfile = () => {
const projectID = useSelector((store)=>store.localVariables.projectId)
@@ -50,7 +51,7 @@ const EmployeeProfile = () => {
}
}, [employeeId]);
-
+ const navigate = useNavigate();
const renderContent = () => {
if (loading) return
Loading
;
switch (activePill) {
@@ -102,74 +103,81 @@ const EmployeeProfile = () => {
]}
>
-
-
-
-
-
-
-
-
-

-
-
{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}
+
+
+
+
+
+
+
+
+
+
+
{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}
+
-
-
-
-
-
Contacts
-
-
- -
-
- Contact Number:
-
- {currentEmployee?.emergencyPhoneNumber || NA}
-
-
- -
-
- Email:
-
- {currentEmployee?.email || NA}
-
-
- -
-
- Contact Person:
-
- {currentEmployee?.emergencyContactPerson}
-
-
- -
-
- Address:
-
-
- -
-
- {currentEmployee?.permanentAddress}
-
-
-
-
+
+
+
Employee Info
+
+
+
+ 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} |
+
+
+
+
+
+
-