Merge branch 'Feature_Task_Management' of https://git.marcoaiot.com/admin/marco.pms.web into Feature_Task_Management

This commit is contained in:
Vikas Nale 2025-04-16 16:13:12 +05:30
commit 0c48ae70b8
7 changed files with 207 additions and 169 deletions

View File

@ -200,7 +200,6 @@ const Dashboard = () => {
<div className="btn-group"> <div className="btn-group">
<button <button
type="button"
className="btn btn-outline-primary btn-sm dropdown-toggle" className="btn btn-outline-primary btn-sm dropdown-toggle"
type="button" type="button"
data-bs-toggle="dropdown" data-bs-toggle="dropdown"

View File

@ -2,49 +2,51 @@ import React from "react";
const EmployeeNav = ({ onPillClick, activePill }) => { const EmployeeNav = ({ onPillClick, activePill }) => {
return ( return (
<div className="nav-align-top "> <div className="col-md-12">
<ul className="nav nav-tabs"> <div className="nav-align-top">
<li className="nav-item"> <ul className="nav nav-pills flex-column flex-sm-row mb-6">
<a <li className="nav-item">
className={`nav-link ${activePill === "account" ? "active" : ""}`} <a
href="#" className={`nav-link ${activePill === "account" ? "active" : ""}`}
onClick={(e) => { href="#"
e.preventDefault(); // Prevent page reload onClick={(e) => {
onPillClick("account"); e.preventDefault(); // Prevent page reload
}} onPillClick("account");
> }}
<i className="bx bx-user bx-sm me-1_5"></i> Account >
</a> <i className="bx bx-user bx-sm me-1_5"></i> Account
</li> </a>
<li className="nav-item"> </li>
<a <li className="nav-item">
className={`nav-link ${ <a
activePill === "attendance" ? "active" : "" className={`nav-link ${
}`} activePill === "attendance" ? "active" : ""
href="#" }`}
onClick={(e) => { href="#"
e.preventDefault(); // Prevent page reload onClick={(e) => {
onPillClick("attendance"); e.preventDefault(); // Prevent page reload
}} onPillClick("attendance");
> }}
<i className="bx bx-group bx-sm me-1_5"></i> Attendances >
</a> <i className="bx bx-group bx-sm me-1_5"></i> Attendances
</li> </a>
<li className="nav-item"> </li>
<a <li className="nav-item">
className={`nav-link ${ <a
activePill === "activities" ? "active" : "" className={`nav-link ${
}`} activePill === "activities" ? "active" : ""
href="#" }`}
onClick={(e) => { href="#"
e.preventDefault(); // Prevent page reload onClick={(e) => {
onPillClick("activities"); e.preventDefault(); // Prevent page reload
}} onPillClick("activities");
> }}
<i className="bx bx-grid-alt bx-sm me-1_5"></i> Activities >
</a> <i className="bx bx-grid-alt bx-sm me-1_5"></i> Activities
</li> </a>
</ul> </li>
</ul>
</div>
</div> </div>
); );
}; };

View File

@ -0,0 +1,24 @@
import React from 'react'
const SuspendEmp = ({onClose}) => {
return (
<div className="modal-dialog modal-md modal-simple mx-sm-auto mx-1 edit-project-modal" role="document">
<div className="modal-content">
<div className="modal-body p-sm-4 p-0">
<button
type="button"
className="btn-close"
onClick={onClose}
aria-label="Close"
></button>
<div className="text-center mb-2">
<h6>Coming Soon</h6>
</div>
</div></div>
</div>
)
}
export default SuspendEmp

View File

@ -6,9 +6,8 @@ import {changeMaster} from "../../slices/localVariablesSlice";
import useMaster from "../../hooks/masterHook/useMaster"; import useMaster from "../../hooks/masterHook/useMaster";
import {useProfile} from "../../hooks/useProfile"; import {useProfile} from "../../hooks/useProfile";
import {useNavigate} from "react-router-dom"; import {useNavigate} from "react-router-dom";
import Avatar from "../../components/common/Avatar";
const Header = () => const Header = () =>{
{
const {profile} = useProfile() const {profile} = useProfile()
const dispatch = useDispatch( changeMaster( "Job Role" ) ) const dispatch = useDispatch( changeMaster( "Job Role" ) )
const {data, loading} = useMaster() const {data, loading} = useMaster()
@ -88,11 +87,9 @@ const Header = () =>
data-bs-toggle="dropdown" data-bs-toggle="dropdown"
> >
<div className="avatar avatar-online"> <div className="avatar avatar-online">
<img <Avatar
src="../assets/img/avatars/00.jpg" firstName={`${profile?.employeeInfo?.firstName}`}
className="w-px-40 h-auto rounded-circle" lastName={`${profile?.employeeInfo?.lastName}`}
alt="avatar-image"
aria-label="Avatar Image"
/> />
</div> </div>
</a> </a>
@ -106,11 +103,9 @@ const Header = () =>
<div className="d-flex"> <div className="d-flex">
<div className="flex-shrink-0 me-3"> <div className="flex-shrink-0 me-3">
<div className="avatar avatar-online"> <div className="avatar avatar-online">
<img <Avatar
src="../assets/img/avatars/00.jpg" firstName={`${profile?.employeeInfo?.firstName}`}
className="w-px-40 h-auto rounded-circle" lastName={`${profile?.employeeInfo?.lastName}`}
alt="avatar-image"
aria-label="Avatar Image"
/> />
</div> </div>
</div> </div>

View File

@ -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) { function generateAvatarText(firstName, lastName) {
if (!firstName) return ""; if (!firstName) return "";
if (!lastName || lastName.trim() === "") { if (!lastName || lastName.trim() === "") {
@ -9,7 +25,8 @@ const Avatar = ({ firstName, lastName }) => {
return `${firstName[0]}${lastName[0]}`.toUpperCase(); return `${firstName[0]}${lastName[0]}`.toUpperCase();
} }
function getRandomBootstrapBgClass() { // Function to map the hash value to a Bootstrap background class
function getBgClassFromHash(hash) {
const bgClasses = [ const bgClasses = [
"bg-primary", "bg-primary",
"bg-secondary", "bg-secondary",
@ -21,21 +38,27 @@ const Avatar = ({ firstName, lastName }) => {
"text-light", "text-light",
]; ];
const randomIndex = Math.floor(Math.random() * bgClasses.length); // Use the hash value to pick a background color from the array
return bgClasses[randomIndex]; 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 ( return (
<> <div className="avatar-wrapper p-1">
<div className="avatar-wrapper p-1"> <div className={`avatar avatar-${size} me-2`}>
<div className="avatar me-2"> <span
<span className={`avatar-initial rounded-circle ${bgClass}`}
className={`avatar-initial rounded-circle ${getRandomBootstrapBgClass()}`} >
> {generateAvatarText(firstName, lastName)}
{generateAvatarText(firstName, lastName)} </span>
</span>
</div>
</div> </div>
</> </div>
); );
}; };

View File

@ -10,6 +10,7 @@ import { useProfile } from "../../hooks/useProfile";
import { hasUserPermission } from "../../utils/authUtils"; import { hasUserPermission } from "../../utils/authUtils";
import { MANAGE_EMPLOYEES } from "../../utils/constants"; import { MANAGE_EMPLOYEES } from "../../utils/constants";
import { useHasUserPermission } from "../../hooks/useHasUserPermission"; import { useHasUserPermission } from "../../hooks/useHasUserPermission";
import SuspendEmp from "../../components/Employee/SuspendEmp";
const EmployeeList = () => const EmployeeList = () =>
{ {
@ -26,10 +27,11 @@ const EmployeeList = () =>
const [employeeList, setEmployeeList] = useState([]); const [employeeList, setEmployeeList] = useState([]);
const [modelConfig, setModelConfig] = useState(); const [modelConfig, setModelConfig] = useState();
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [itemsPerPage] = useState(5); const [itemsPerPage] = useState(10);
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [searchText, setSearchText] = useState(""); const [searchText, setSearchText] = useState("");
const [filteredData, setFilteredData] = useState([]); const [ filteredData, setFilteredData ] = useState( [] );
const [showModal, setShowModal] = useState(false);
const navigate = useNavigate(); const navigate = useNavigate();
const handleSearch = (e) => { const handleSearch = (e) => {
@ -74,7 +76,6 @@ const EmployeeList = () =>
const closeModal = () => { const closeModal = () => {
setIsCreateModalOpen(false); setIsCreateModalOpen(false);
const modalElement = document.getElementById("managerole-modal"); const modalElement = document.getElementById("managerole-modal");
if (modalElement) { if (modalElement) {
modalElement.classList.remove("show"); modalElement.classList.remove("show");
@ -83,6 +84,8 @@ const EmployeeList = () =>
document.querySelector(".modal-backdrop").remove(); document.querySelector(".modal-backdrop").remove();
} }
}; };
const handleShow = () => setShowModal(true);
const handleClose = () => setShowModal( false );
const handleConfigData = (config) => { const handleConfigData = (config) => {
setModelConfig(config); setModelConfig(config);
@ -99,6 +102,17 @@ const EmployeeList = () =>
{isCreateModalOpen && ( {isCreateModalOpen && (
<ManageEmp employeeId={modelConfig} onClosed={closeModal} /> <ManageEmp employeeId={modelConfig} onClosed={closeModal} />
)} )}
<div
className={`modal fade ${showModal ? 'show' : ''}`}
tabIndex="-1"
role="dialog"
style={{ display: showModal ? 'block' : 'none' }}
aria-hidden={!showModal}
>
<SuspendEmp onClose={handleClose}/>
</div>
<div className="container-xxl flex-grow-1 container-p-y"> <div className="container-xxl flex-grow-1 container-p-y">
<Breadcrumb <Breadcrumb
data={[ data={[
@ -184,35 +198,8 @@ const EmployeeList = () =>
className="dropdown-item" className="dropdown-item"
href="#" href="#"
> >
<i className="bx bx-printer me-1"></i> {/* <i className="bx bx-printer me-1"></i> */}
Print Coming Soon
</a>
</li>
<li>
<a
aria-label="dropdown item another action"
className="dropdown-item"
href="#"
>
<i className="bx bx-file me-1"></i>
Csv
</a>
</li>
<li>
<a
aria-label="dropdown item something else here"
className="dropdown-item"
href="#"
>
<i className="bx bxs-file-export me-1"></i>
Excel
</a>
</li>
<li>
<a className="dropdown-item" href="#">
<i className="bx bxs-file-pdf me-1"></i>
Pdf
</a> </a>
</li> </li>
</ul> </ul>
@ -442,7 +429,7 @@ const EmployeeList = () =>
> >
Edit Edit
</Link> </Link>
<button className="dropdown-item"> <button className="dropdown-item" onClick={handleShow}>
Suspend Suspend
</button> </button>
<button <button

View File

@ -1,4 +1,4 @@
import React,{useState,useEffect} from "react"; import React, { useState, useEffect } from "react";
import EmpProfile from "../../components/Employee/EmpProfile"; import EmpProfile from "../../components/Employee/EmpProfile";
import axios from "axios"; import axios from "axios";
import Breadcrumb from "../../components/common/Breadcrumb"; import Breadcrumb from "../../components/common/Breadcrumb";
@ -9,7 +9,8 @@ import { useEmployeeProfile, useEmployees, useEmployeesByProject } from "../../h
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import EmployeeRepository from "../../repositories/EmployeeRepository"; import EmployeeRepository from "../../repositories/EmployeeRepository";
import { ComingSoonPage } from "../Misc/ComingSoonPage"; import { ComingSoonPage } from "../Misc/ComingSoonPage";
import { useNavigate } from "react-router-dom";
import Avatar from "../../components/common/Avatar";
const EmployeeProfile = () => { const EmployeeProfile = () => {
const projectID = useSelector((store)=>store.localVariables.projectId) const projectID = useSelector((store)=>store.localVariables.projectId)
@ -50,7 +51,7 @@ const EmployeeProfile = () => {
} }
}, [employeeId]); }, [employeeId]);
const navigate = useNavigate();
const renderContent = () => { const renderContent = () => {
if (loading) return <div>Loading</div>; if (loading) return <div>Loading</div>;
switch (activePill) { switch (activePill) {
@ -102,74 +103,81 @@ const EmployeeProfile = () => {
]} ]}
></Breadcrumb> ></Breadcrumb>
<div className="row"> <div className="row">
<div className="col-12 col-md-8 col-lg-4 order-1 order-lg-1"> <div className="col-12 col-md-8 col-lg-4 order-1 order-lg-1">
<div className="row"> <div className="row">
<div className="col-12 mb-4"> <div className="col-12 mb-4">
<div className="card"> <div className="card">
<div className="card-body"> <div className="card-body">
<div className="d-flex flex-row flex-lg-column"> <div className="d-flex flex-row flex-lg-column">
<div className="d-flex flex-column justify-content-center align-items-center text-center"> <div className="d-flex flex-column justify-content-center align-items-center text-center">
<img <Avatar
src={`../../../public/img/avatars/${currentEmployee.gender}.jpg`} firstName={`${currentEmployee?.firstName}`}
alt="user-avatar" lastName={`${currentEmployee?.lastName}`}
className="d-block rounded" size={"lg"}
height="100" />
width="100" <div className="py-2">
aria-label="Account image" <p className="h6">{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}</p>
id="uploadedAvatar" </div>
/>
<div className="py-2">
<p className="h6">{`${currentEmployee?.firstName} ${currentEmployee?.lastName}`}</p>
</div> </div>
<hr className="my-2" /> <div className="w-100 d-flex flex-column justify-content-start">
</div> <div className="mt-3 w-100">
<div className="w-100 d-flex flex-row flex-sm-column justify-content-sm-start justify-content-around"> <h6 className="mb-2 text-muted text-start">Employee Info</h6>
<div className="text-wrap"> <table className="table table-borderless mb-3">
<small className="card-text text-uppercase text-muted small">Contacts</small> <tbody>
<ul className="list-unstyled my-3 py-1"> <tr>
<td className="fw-medium text-start">Email:</td>
<td className="text-start">{currentEmployee?.email || <em>NA</em>}</td>
</tr>
<tr>
<td className="fw-medium text-start">Phone Number:</td>
<td className="text-start">{currentEmployee?.phoneNumber || <em>NA</em>}</td>
</tr>
<tr>
<td className="fw-medium text-start">Emergency Contact Person:</td>
<td className="text-start">{currentEmployee?.emergencyContactPerson || <em>NA</em>}</td>
</tr>
<tr>
<td className="fw-medium text-start">Emergency Contact Number:</td>
<td className="text-start">{currentEmployee?.emergencyPhoneNumber || <em>NA</em>}</td>
</tr>
<li className="d-flex align-items-center mb-4"> <tr>
<i className="bx bx-phone"></i> <td className="fw-medium text-start">Gender:</td>
<span className="fw-medium mx-2">Contact Number:</span> <td className="text-start">{currentEmployee?.gender || <em>NA</em>}</td>
<span className={`${currentEmployee?.emergencyPhoneNumber ? "" : "text-muted"}`}> </tr>
{currentEmployee?.emergencyPhoneNumber || <em>NA</em>} <tr>
</span> <td className="fw-medium text-start">Birth Date:</td>
</li> <td className="text-start">{currentEmployee?.birthDate ? new Date(currentEmployee.birthDate).toLocaleDateString() : <em>NA</em>}</td>
<li className="d-flex align-items-center mb-4 text-start"> </tr>
<i className="bx bx-envelope"></i>
<span className="fw-medium mx-2">Email:</span>
<span className={`text-break text-wrap ${currentEmployee?.email ? "" : "text-muted"}`}>
{currentEmployee?.email || <em className="muted">NA</em>}
</span>
</li>
<li className="d-flex align-items-center mb-4">
<i className="bx bx-user"></i>
<span className="fw-medium mx-2">Contact Person:</span>
<span className="">
{currentEmployee?.emergencyContactPerson}
</span>
</li>
<li className="d-flex align-items-center text-wrap ">
<i className="bx bx-flag"></i>
<span className="fw-medium mx-2">Address:</span>
</li>
<li className="d-flex align-items-start test-start mb-2">
<span className={`${currentEmployee?.permanentAddress ? "" : "ms-4"}`}>
{currentEmployee?.permanentAddress}
</span>
</li>
</ul> <tr>
<td className="fw-medium text-start">Joining Date:</td>
<td className="text-start">{currentEmployee?.joiningDate ? new Date(currentEmployee.joiningDate).toLocaleDateString() : <em>NA</em>}</td>
</tr>
<tr>
<td className="fw-medium text-start">Job Role:</td>
<td className="text-start">{currentEmployee?.jobRole || <em>NA</em>}</td>
</tr>
<tr>
<td className="fw-medium text-start">Address:</td>
<td className="text-start">{currentEmployee?.currentAddress || <em>NA</em>}</td>
</tr>
</tbody>
</table>
</div>
<button className="btn btn-primary btn-block" onClick={() => navigate(`/employee/manage/${currentEmployee?.id}`)}>
Edit Profile
</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div className="col-12 col-lg-8 order-2 order-lg-2 mb-4"> <div className="col-12 col-lg-8 order-2 order-lg-2 mb-4">
<div className="row"> <div className="row">