);
};
diff --git a/src/components/Employee/SuspendEmp.jsx b/src/components/Employee/SuspendEmp.jsx
new file mode 100644
index 00000000..a508e62c
--- /dev/null
+++ b/src/components/Employee/SuspendEmp.jsx
@@ -0,0 +1,24 @@
+import React from 'react'
+
+const SuspendEmp = ({onClose}) => {
+ return (
+
+
+ )
+}
+
+export default SuspendEmp
\ No newline at end of file
diff --git a/src/components/Layout/Header.jsx b/src/components/Layout/Header.jsx
index ae380b24..dcaa306f 100644
--- a/src/components/Layout/Header.jsx
+++ b/src/components/Layout/Header.jsx
@@ -6,9 +6,8 @@ import {changeMaster} from "../../slices/localVariablesSlice";
import useMaster from "../../hooks/masterHook/useMaster";
import {useProfile} from "../../hooks/useProfile";
import {useNavigate} from "react-router-dom";
-
-const Header = () =>
-{
+import Avatar from "../../components/common/Avatar";
+const Header = () =>{
const {profile} = useProfile()
const dispatch = useDispatch( changeMaster( "Job Role" ) )
const {data, loading} = useMaster()
@@ -88,11 +87,9 @@ const Header = () =>
data-bs-toggle="dropdown"
>
-
diff --git a/src/components/common/Avatar.jsx b/src/components/common/Avatar.jsx
index a09d97d3..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";
-const Avatar = ({ firstName, lastName }) => {
+// 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 }) => {
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 }) => {
"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/EmployeeList.jsx b/src/pages/employee/EmployeeList.jsx
index 0e0f87a6..301e61a7 100644
--- a/src/pages/employee/EmployeeList.jsx
+++ b/src/pages/employee/EmployeeList.jsx
@@ -10,6 +10,7 @@ import { useProfile } from "../../hooks/useProfile";
import { hasUserPermission } from "../../utils/authUtils";
import { MANAGE_EMPLOYEES } from "../../utils/constants";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
+import SuspendEmp from "../../components/Employee/SuspendEmp";
const EmployeeList = () =>
{
@@ -26,10 +27,11 @@ const EmployeeList = () =>
const [employeeList, setEmployeeList] = useState([]);
const [modelConfig, setModelConfig] = useState();
const [currentPage, setCurrentPage] = useState(1);
- const [itemsPerPage] = useState(5);
+ const [itemsPerPage] = useState(10);
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [searchText, setSearchText] = useState("");
- const [filteredData, setFilteredData] = useState([]);
+ const [ filteredData, setFilteredData ] = useState( [] );
+ const [showModal, setShowModal] = useState(false);
const navigate = useNavigate();
const handleSearch = (e) => {
@@ -74,7 +76,6 @@ const EmployeeList = () =>
const closeModal = () => {
setIsCreateModalOpen(false);
-
const modalElement = document.getElementById("managerole-modal");
if (modalElement) {
modalElement.classList.remove("show");
@@ -83,7 +84,9 @@ const EmployeeList = () =>
document.querySelector(".modal-backdrop").remove();
}
};
-
+ const handleShow = () => setShowModal(true);
+ const handleClose = () => setShowModal( false );
+
const handleConfigData = (config) => {
setModelConfig(config);
};
@@ -99,6 +102,17 @@ const EmployeeList = () =>
{isCreateModalOpen && (
)}
+
+
+
+
+
className="dropdown-item"
href="#"
>
-
- Print
-
-
-
-
-
- Csv
-
-
-
-
-
- Excel
-
-
-
-
-
-
- Pdf
+ {/* */}
+ Coming Soon
@@ -442,7 +429,7 @@ const EmployeeList = () =>
>
Edit
-
-
-
-
-
-
-
-
-
-

-
-
{`${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} |
+
+
+
+
+
navigate(`/employee/manage/${currentEmployee?.id}`)}>
+ Edit Profile
+
+
-