Compare commits

...

42 Commits

Author SHA1 Message Date
6f247fb0e9 Merge branch 'SingalR_Integration' of https://git.marcoaiot.com/admin/marco.pms.web into SingalR_Integration 2025-06-17 17:19:02 +05:30
8431e856aa Added signalR functionality in Project Infrastructure 2025-06-17 17:18:59 +05:30
782ace9d1c refreshing globle project is created new project and user have manage project permission 2025-06-17 17:18:59 +05:30
fdff7f7b41 Fixed rebase conflicts 2025-06-17 17:18:59 +05:30
8832ff1c51 Implemented signalr for action assigning employee to project 2025-06-17 17:18:59 +05:30
24dc481169 Implemented signalR for create and update project 2025-06-17 17:18:28 +05:30
351e5a2b0d Implemented attendance funcationality in attendance module 2025-06-17 17:14:25 +05:30
2848177908 Change ../services/signalRService from ../services/SignalRService 2025-06-17 17:11:30 +05:30
b767641643 Avoided API calls 2025-06-17 17:11:30 +05:30
b24edba8f7 Implmeneted signalR in today's attendance 2025-06-17 17:11:29 +05:30
8217308db9 Implemented signalr for action assigning employee to project 2025-06-17 17:07:54 +05:30
ab5a598562 Implemented signalr in assign team tab in project details 2025-06-17 17:07:54 +05:30
9530f9ca87 Implemented attendance funcationality in attendance module 2025-06-17 17:07:54 +05:30
9b6fa84d0d Change ../services/signalRService from ../services/SignalRService 2025-06-17 17:07:54 +05:30
5567928c7f Avoided API calls 2025-06-17 17:07:53 +05:30
88efbf5542 Implmeneted signalR in today's attendance 2025-06-17 17:07:53 +05:30
ed2fa2d5b0 Implemented signalR for create and update project 2025-06-17 17:07:53 +05:30
a0e4b1c5ed Changed some functionallity in attendance 2025-06-17 17:07:53 +05:30
90a77d357f Implemented attendance funcationality in attendance module 2025-06-17 17:07:53 +05:30
8ad375ede4 Added lognpolling in signalR request 2025-06-17 17:07:53 +05:30
6f3a8bd7c9 Added base url in signalrServies 2025-06-17 17:07:53 +05:30
2fbf0f98ef Change ../services/signalRService from ../services/SignalRService 2025-06-17 17:07:53 +05:30
36d70b3850 Avoided API calls 2025-06-17 17:07:53 +05:30
a3381bb2e6 Implmeneted signalR in today's attendance 2025-06-17 17:07:53 +05:30
Pramod Mahajan
6f88980986 Fix DOM nesting warning by replacing <p> with <div> in comment note section 2025-06-14 11:11:07 +05:30
Pramod Mahajan
6d2c2c5e0b changed preview reported images 2025-06-14 11:05:42 +05:30
Pramod Mahajan
f48d05ecee changed hook name , replaced properly related logic name 2025-06-14 10:46:33 +05:30
Pramod Mahajan
dee44c63aa handled loading properly 2025-06-14 10:45:43 +05:30
Pramod Mahajan
b76ca68059 changed class to className 2025-06-14 10:21:24 +05:30
Pramod Mahajan
7c9607cb78 resolved localCompare error 2025-06-13 18:06:09 +05:30
Pramod Mahajan
cbf376d5b6 added pending filter for attendaces using toggle buttons 2025-06-13 17:52:22 +05:30
Pramod Mahajan
00902fff9f fixed togger for active and inactive employee 2025-06-13 13:27:34 +05:30
Pramod Mahajan
c254b98405 Fixed image scaling inside preview container to fully fill the space 2025-06-13 13:03:27 +05:30
41f3628d45 For project progress widget set default selection 15W 2025-06-13 09:39:27 +05:30
31a9f55b63 - Add shot name in project lobal selection
- Sort jobrole in edit employee
2025-06-13 00:56:02 +05:30
70ac3e0344 Changes in Employee form allow searching form all the fields. 2025-06-13 00:22:23 +05:30
409d98f923 Merge branch 'activity_image' of https://git.marcoaiot.com/admin/marco.pms.web into activity_image 2025-06-13 00:02:29 +05:30
Pramod Mahajan
1f0255bc55 Merge branch 'activity_image' of https://git.marcoaiot.com/admin/marco.pms.web into activity_image 2025-06-12 23:57:59 +05:30
edf092e85e Creating a toggle button in Project Progress. 2025-06-12 23:56:43 +05:30
Pramod Mahajan
9043cfd49e prevent to set first project from project-list at component mount 2025-06-12 23:56:36 +05:30
da440060e8 - Some cosmatic changes on Activity Details popup
- Header Global project filter hite set to ax 300px a
- header global project list sorted by name
2025-06-12 23:06:51 +05:30
Pramod Mahajan
3ed5999f29 added attachment views 2025-06-12 22:54:08 +05:30
24 changed files with 770 additions and 522 deletions

View File

@ -5,9 +5,15 @@ import { convertShortTime } from "../../utils/dateUtils";
import RenderAttendanceStatus from "./RenderAttendanceStatus";
import usePagination from "../../hooks/usePagination";
import { useNavigate } from "react-router-dom";
import {ITEMS_PER_PAGE} from "../../utils/constants";
import { ITEMS_PER_PAGE } from "../../utils/constants";
const Attendance = ({ attendance, getRole, handleModalData }) => {
const Attendance = ({
attendance,
getRole,
handleModalData,
setshowOnlyCheckout,
showOnlyCheckout,
}) => {
const [loading, setLoading] = useState(false);
const navigate = useNavigate();
const [todayDate, setTodayDate] = useState(new Date());
@ -19,7 +25,7 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
const sortByName = (a, b) => {
const nameA = (a.firstName + a.lastName).toLowerCase();
const nameB = (b.firstName + b.lastName).toLowerCase();
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
};
// Filter employees based on activity
@ -39,41 +45,47 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
return (
<>
<div className="table-responsive text-nowrap">
<div className="d-flex text-start align-items-center py-2">
<strong>Date : {todayDate.toLocaleDateString("en-GB")}</strong>
<div className="form-check form-switch text-start m-0 ms-5">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showOnlyCheckout}
onChange={(e) => setshowOnlyCheckout(e.target.checked)}
/>
<label className="form-check-label ms-0">Show Pending</label>
</div>
</div>
{attendance && attendance.length > 0 && (
<>
<table className="table ">
<thead>
<tr className="border-none" style={{ textAlign: 'left' }}>
<td style={{ borderBottom: 'none' }}>
<strong>Date : {todayDate.toLocaleDateString('en-GB')}</strong>
</td>
<td style={{ paddingLeft: '20px', borderBottom: 'none' }}></td>
</tr>
<tr>
<th className="border-top-0" colSpan={2}>
Name
</th>
<th className="border-top-0">Role</th>
<th className="border-top-0">
<tr className="border-top-1">
<th colSpan={2}>Name</th>
<th>Role</th>
<th>
<i className="bx bxs-down-arrow-alt text-success"></i>
Check-In
</th>
<th className="border-top-0">
<th>
<i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out
</th>
<th className="border-top-0">Actions</th>
<th>Actions</th>
</tr>
</thead>
<tbody className="table-border-bottom-0">
<tbody className="table-border-bottom-0 ">
{currentItems &&
currentItems
.sort((a, b) => {
// If checkInTime exists, compare it, otherwise, treat null as earlier than a date
const checkInA = a.checkInTime
const checkInA = a?.checkInTime
? new Date(a.checkInTime)
: new Date(0);
const checkInB = b.checkInTime
const checkInB = b?.checkInTime
? new Date(b.checkInTime)
: new Date(0);
return checkInB - checkInA; // Sort in descending order of checkInTime
@ -131,12 +143,13 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
</tbody>
</table>
{!loading>20 && (
{!loading > 20 && (
<nav aria-label="Page ">
<ul className="pagination pagination-sm justify-content-end py-1">
<li
className={`page-item ${currentPage === 1 ? "disabled" : ""
}`}
className={`page-item ${
currentPage === 1 ? "disabled" : ""
}`}
>
<button
className="page-link btn-xs"
@ -148,8 +161,9 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
{[...Array(totalPages)].map((_, index) => (
<li
key={index}
className={`page-item ${currentPage === index + 1 ? "active" : ""
}`}
className={`page-item ${
currentPage === index + 1 ? "active" : ""
}`}
>
<button
className="page-link "
@ -160,8 +174,9 @@ const Attendance = ({ attendance, getRole, handleModalData }) => {
</li>
))}
<li
className={`page-item ${currentPage === totalPages ? "disabled" : ""
}`}
className={`page-item ${
currentPage === totalPages ? "disabled" : ""
}`}
>
<button
className="page-link "

View File

@ -12,7 +12,6 @@ import eventBus from "../../services/eventBus";
const usePagination = (data, itemsPerPage) => {
const [currentPage, setCurrentPage] = useState(1);
const maxPage = Math.ceil(data.length / itemsPerPage);
const currentItems = useMemo(() => {
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
@ -22,10 +21,21 @@ const usePagination = (data, itemsPerPage) => {
const paginate = useCallback((pageNumber) => setCurrentPage(pageNumber), []);
const resetPage = useCallback(() => setCurrentPage(1), []);
return { currentPage, totalPages: maxPage, currentItems, paginate, resetPage };
return {
currentPage,
totalPages: maxPage,
currentItems,
paginate,
resetPage,
};
};
const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
const AttendanceLog = ({
handleModalData,
projectId,
setshowOnlyCheckout,
showOnlyCheckout,
}) => {
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
const dispatch = useDispatch();
const { data, loading, error } = useSelector((store) => store.attendanceLogs);
@ -55,7 +65,7 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
const sortByName = (a, b) => {
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
};
useEffect(() => {
@ -84,14 +94,24 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
const group3 = filteredData
.filter((d) => d.activity === 1 && isBeforeToday(d.checkInTime))
.sort(sortByName);
const group4 = filteredData
.filter((d) => d.activity === 4 && isBeforeToday(d.checkOutTime));
const group4 = filteredData.filter(
(d) => d.activity === 4 && isBeforeToday(d.checkOutTime)
);
const group5 = filteredData
.filter((d) => d.activity === 2 && isBeforeToday(d.checkOutTime))
.sort(sortByName);
const group6 = filteredData.filter((d) => d.activity === 5).sort(sortByName);
const group6 = filteredData
.filter((d) => d.activity === 5)
.sort(sortByName);
const sortedList = [...group1, ...group2, ...group3, ...group4, ...group5, ...group6];
const sortedList = [
...group1,
...group2,
...group3,
...group4,
...group5,
...group6,
];
// Group by date
const groupedByDate = sortedList.reduce((acc, item) => {
@ -104,7 +124,9 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
}, {});
// Sort dates in descending order
const sortedDates = Object.keys(groupedByDate).sort((a, b) => new Date(b) - new Date(a));
const sortedDates = Object.keys(groupedByDate).sort(
(a, b) => new Date(b) - new Date(a)
);
// Create the final sorted array
const finalData = sortedDates.flatMap((date) => groupedByDate[date]);
@ -115,10 +137,13 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
filtering(data)
}, [data, showOnlyCheckout]);
const { currentPage, totalPages, currentItems: paginatedAttendances, paginate, resetPage } = usePagination(
processedData,
20
);
const {
currentPage,
totalPages,
currentItems: paginatedAttendances,
paginate,
resetPage,
} = usePagination(processedData, 20);
// Reset to the first page whenever processedData changes (due to switch on/off)
useEffect(() => {
@ -154,57 +179,89 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
return (
<>
<div
className="dataTables_length text-start py-2 d-flex justify-content-between"
id="DataTables_Table_0_length"
>
<div className="col-md-3 my-0 ">
<DateRangePicker onRangeChange={setDateRange} defaultStartDate={yesterday} />
</div>
<div className="col-md-2 m-0 text-end">
<i
className={`bx bx-refresh cursor-pointer fs-4 ${loading || isRefreshing ? "spin" : ""
}`}
title="Refresh"
onClick={() => setIsRefreshing(true)}
<div
className="dataTables_length text-start py-2 d-flex justify-content-between"
id="DataTables_Table_0_length"
>
<div className="d-flex align-items-center my-0 ">
<DateRangePicker
onRangeChange={setDateRange}
defaultStartDate={yesterday}
/>
<div className="form-check form-switch text-start m-0 ms-5">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showOnlyCheckout}
onChange={(e) => setshowOnlyCheckout(e.target.checked)}
/>
<label className="form-check-label ms-0">Show Pending</label>
</div>
</div>
<div className="table-responsive text-nowrap" style={{ minHeight: "250px" }}>
{data && data.length > 0 && (
<table className="table mb-0">
<thead>
<div className="col-md-2 m-0 text-end">
<i
className={`bx bx-refresh cursor-pointer fs-4 ${
loading || isRefreshing ? "spin" : ""
}`}
title="Refresh"
onClick={() => setIsRefreshing(true)}
/>
</div>
</div>
<div
className="table-responsive text-nowrap"
style={{ minHeight: "250px" }}
>
{data && data.length > 0 && (
<table className="table mb-0">
<thead>
<tr>
<th className="border-top-1" colSpan={2}>
Name
</th>
<th className="border-top-1">Date</th>
<th>
<i className="bx bxs-down-arrow-alt text-success"></i>{" "}
Check-In
</th>
<th>
<i className="bx bxs-up-arrow-alt text-danger"></i> Check-Out
</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{(loading || isRefreshing) && (
<tr>
<th className="border-top-1" colSpan={2}>
Name
</th>
<th className="border-top-1">Date</th>
<th>
<i className="bx bxs-down-arrow-alt text-success"></i> Check-In
</th>
<th>
<i className="bx bxs-up-arrow-alt text-danger"></i> Check-Out
</th>
<th>Action</th>
<td colSpan={6}>Loading...</td>
</tr>
</thead>
<tbody>
{(loading || isRefreshing) && (
<tr>
<td colSpan={6}>Loading...</td>
</tr>
)}
{!loading && !isRefreshing && paginatedAttendances.reduce((acc, attendance, index, arr) => {
const currentDate = moment(attendance.checkInTime || attendance.checkOutTime).format("YYYY-MM-DD");
)}
{!loading &&
!isRefreshing &&
paginatedAttendances.reduce((acc, attendance, index, arr) => {
const currentDate = moment(
attendance.checkInTime || attendance.checkOutTime
).format("YYYY-MM-DD");
const previousAttendance = arr[index - 1];
const previousDate = previousAttendance ? moment(previousAttendance.checkInTime || previousAttendance.checkOutTime).format("YYYY-MM-DD") : null;
const previousDate = previousAttendance
? moment(
previousAttendance.checkInTime ||
previousAttendance.checkOutTime
).format("YYYY-MM-DD")
: null;
if (!previousDate || currentDate !== previousDate) {
acc.push(
<tr key={`header-${currentDate}`} className="table-row-header">
<tr
key={`header-${currentDate}`}
className="table-row-header"
>
<td colSpan={6} className="text-start">
<strong>{moment(currentDate).format("DD-MM-YYYY")}</strong>
<strong>
{moment(currentDate).format("DD-MM-YYYY")}
</strong>
</td>
</tr>
);
@ -218,10 +275,7 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
lastName={attendance.lastName}
/>
<div className="d-flex flex-column">
<a
href="#"
className="text-heading text-truncate"
>
<a href="#" className="text-heading text-truncate">
<span className="fw-normal">
{attendance.firstName} {attendance.lastName}
</span>
@ -230,11 +284,15 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
</div>
</td>
<td>
{moment(attendance.checkInTime || attendance.checkOutTime).format("DD-MMM-YYYY")}
{moment(
attendance.checkInTime || attendance.checkOutTime
).format("DD-MMM-YYYY")}
</td>
<td>{convertShortTime(attendance.checkInTime)}</td>
<td>
{attendance.checkOutTime ? convertShortTime(attendance.checkOutTime) : "--"}
{attendance.checkOutTime
? convertShortTime(attendance.checkOutTime)
: "--"}
</td>
<td className="text-center">
<RenderAttendanceStatus
@ -248,40 +306,55 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
);
return acc;
}, [])}
</tbody>
</table>
)}
{!loading && !isRefreshing && data.length === 0 && <span>No employee logs</span>}
{error && !loading && !isRefreshing && (
<tr>
<td colSpan={6}>{error}</td>
</tr>
)}
</div>
</tbody>
</table>
)}
{!loading && !isRefreshing && data.length === 0 && (
<span>No employee logs</span>
)}
{error && !loading && !isRefreshing && (
<tr>
<td colSpan={6}>{error}</td>
</tr>
)}
</div>
{!loading && !isRefreshing && processedData.length > 10 && (
<nav aria-label="Page ">
<ul className="pagination pagination-sm justify-content-end py-1">
<li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>
<button className="page-link btn-xs" onClick={() => paginate(currentPage - 1)}>
<button
className="page-link btn-xs"
onClick={() => paginate(currentPage - 1)}
>
&laquo;
</button>
</li>
{Array.from({ length: totalPages }, (_, i) => i + 1).map((pageNumber) => (
<li
key={pageNumber}
className={`page-item ${currentPage === pageNumber ? "active" : ""}`}
>
<button className="page-link" onClick={() => paginate(pageNumber)}>
{pageNumber}
</button>
</li>
))}
{Array.from({ length: totalPages }, (_, i) => i + 1).map(
(pageNumber) => (
<li
key={pageNumber}
className={`page-item ${
currentPage === pageNumber ? "active" : ""
}`}
>
<button
className="page-link"
onClick={() => paginate(pageNumber)}
>
{pageNumber}
</button>
</li>
)
)}
<li
className={`page-item ${currentPage === totalPages ? "disabled" : ""}`}
className={`page-item ${
currentPage === totalPages ? "disabled" : ""
}`}
>
<button className="page-link" onClick={() => paginate(currentPage + 1)}>
<button
className="page-link"
onClick={() => paginate(currentPage + 1)}
>
&raquo;
</button>
</li>

View File

@ -28,10 +28,10 @@ const InfraPlanning = () =>
const {projects_Details, loading: project_deatilsLoader, error: project_error,refetch} = useProjectDetails( selectedProject )
const reloadedData = useSelector( ( store ) => store.localVariables.reload )
useEffect( () =>
{
dispatch(setProjectId(projects[0]?.id))
}, [ projects ] )
// useEffect( () =>
// {
// dispatch(setProjectId(projects[0]?.id))
// }, [ projects ] )
useEffect( () =>
{

View File

@ -22,7 +22,7 @@ const Regularization = ({ handleRequest }) => {
const sortByName = (a, b) => {
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
};
const handler = useCallback(

View File

@ -8,6 +8,7 @@ import showToast from "../../services/toastService";
import Avatar from "../common/Avatar";
import { getBgClassFromHash } from "../../utils/projectStatus";
import { cacheData, getCachedData } from "../../slices/apiDataManager";
import ImagePreview from "../common/ImagePreview";
const schema = z.object({
comment: z.string().min(1, "Comment cannot be empty"),
@ -40,7 +41,9 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
useEffect(() => {
const taskList = getCachedData("taskList");
if (taskList && taskList.data && commentsData?.id) {
const currentTask = taskList.data.find(task => task.id === commentsData.id);
const currentTask = taskList.data.find(
(task) => task.id === commentsData.id
);
if (currentTask && currentTask.comments) {
setComment(currentTask.comments);
} else {
@ -99,157 +102,183 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
showToast("Successfully Sent", "success");
} catch (error) {
setloading(false);
showToast(error.response.data?.message || "Something went wrong", "error");
showToast(
error.response.data?.message || "Something went wrong",
"error"
);
}
};
return (
<div
className="modal-dialog modal-lg modal-simple report-task-comments-modal mx-sm-auto mx-1"
role="document"
>
<div className="modal-content">
<div className="modal-body p-sm-4 p-0">
<button
type="button"
className="btn-close"
onClick={closeModal}
aria-label="Close"
></button>
<h5 className=" text-center mb-2">
Activity Summary
</h5>
<div className="p-1">
<div className="modal-body p-sm-4 p-0">
<h5 className=" text-center mb-2">Activity Summary</h5>
<p className="small-text text-start my-2">
{commentsData?.workItem?.workArea?.floor?.building?.description}
</p>
<p className="fw-bold my-2 text-start">
Location :
<span className="fw-normal ms-2 text-start">
{`${commentsData?.workItem?.workArea?.floor?.building?.name}`}{" "}
<i className="bx bx-chevron-right"></i>{" "}
{`${commentsData?.workItem?.workArea?.floor?.floorName} `}{" "}
<i className="bx bx-chevron-right"></i>
{`${commentsData?.workItem?.workArea?.areaName}`}
<i className="bx bx-chevron-right"></i>
{` ${commentsData?.workItem?.activityMaster?.activityName}`}
</span>
</p>
<p className="fw-bold my-2 text-start">
Assigned By :
<span className=" ms-2">
{commentsData?.assignedBy?.firstName +
" " +
commentsData?.assignedBy?.lastName}
</span>{" "}
</p>
<p className="fw-bold my-2 text-start">
Assigned By :
<span className=" ms-2">
{commentsData?.assignedBy?.firstName +
" " +
commentsData?.assignedBy?.lastName}
</span>{" "}
</p>
<p className="fw-bold my-2 text-start">
Reported By :
<span className=" ms-2"> -
{/* {commentsData?.assignedBy?.firstName +
<p className="fw-bold my-2 text-start">
Reported By :
<span className=" ms-2">
{" "}
-
{/* {commentsData?.assignedBy?.firstName +
" " +
commentsData?.assignedBy?.lastName} */}
</span>{" "}
</p>
</span>{" "}
</p>
<p className="fw-bold my-2 text-start">
Location :
<span className="fw-normal ms-2 text-start">
{`${commentsData?.workItem?.workArea?.floor?.building?.name}`}{" "}
<i className="bx bx-chevron-right"></i>{" "}
{`${commentsData?.workItem?.workArea?.floor?.floorName} `}{" "}
<i className="bx bx-chevron-right"></i>
{`${commentsData?.workItem?.workArea?.areaName}`}
<i className="bx bx-chevron-right"></i>
{` ${commentsData?.workItem?.activityMaster?.activityName}`}
</span>
</p>
<p className="fw-bold my-2 text-start">
Planned Work: {commentsData?.plannedTask}{" "}
{
commentsData?.workItem?.activityMaster
?.unitOfMeasurement
}
</p>
<p className="fw-bold my-2 text-start">
Planned Work: {commentsData?.plannedTask}{" "}
{commentsData?.workItem?.activityMaster?.unitOfMeasurement}
</p>
{commentsData?.reportedDate != null && (
<p className="fw-bold my-2 text-start">
{" "}
Completed Work : {commentsData?.completedTask}{" "}
{
commentsData?.workItem?.activityMaster
?.unitOfMeasurement
}
{commentsData?.workItem?.activityMaster?.unitOfMeasurement}
</p>
<div className="d-flex align-items-center flex-wrap">
<p className="fw-bold text-start m-0 me-1">Team :</p>
<div className="d-flex flex-wrap align-items-center gap-2">
{commentsData?.teamMembers?.map((member, idx) => (
<span key={idx} className="d-flex align-items-center">
<Avatar
firstName={member?.firstName}
lastName={member?.lastName}
size="xs"
/>
{member?.firstName + " " + member?.lastName}
</span>
))}
</div>
)}
{!commentsData?.reportedDate && (
<p className="fw-bold my-2 text-start"> Completed Work : &nbsp;-</p>
)}
<div className="d-flex align-items-center flex-wrap">
<p className="fw-bold text-start m-0 me-1">Team :</p>
<div className="d-flex flex-wrap align-items-center gap-2">
{commentsData?.teamMembers?.map((member, idx) => (
<span key={idx} className="d-flex align-items-center">
<Avatar
firstName={member?.firstName}
lastName={member?.lastName}
size="xs"
/>
{member?.firstName + " " + member?.lastName}
</span>
))}
</div>
<form onSubmit={handleSubmit(onSubmit)} className="text-start">
<label className="fw-bold text-start my-1">Add comment :</label>
<textarea
{...register("comment")}
className="form-control"
id="exampleFormControlTextarea1"
placeholder="Enter comment"
/>
{errors.comment && (
<div className="danger-text">{errors.comment.message}</div>
)}
<div className="text-end my-1">
<button
type="button"
className="btn btn-sm btn-secondary"
onClick={closeModal}
data-bs-dismiss="modal"
>
Close
</button>
<button type="submit" className="btn btn-sm btn-primary ms-2" disabled={loading}>
{loading ? "Sending..." : "Comment"}
</button>
</div>
</form>
<ul
className="list-group px-0 mx-0 overflow-auto border-0"
ref={containerRef}
>
{comments &&
comments
?.slice()
.reverse()
.map((data, idx) => {
const fullName = `${data?.employee?.firstName} ${data?.employee?.lastName}`;
return (
<li
className={`list-group-item list-group-item-action border-none my-1 p-1`}
key={idx}
>
<div
className={`li-wrapper d-flex justify-content-start align-items-center my-0`}
>
<div className="avatar avatar-xs me-1">
<span
className={`avatar-initial rounded-circle bg-label-primary`}
>
{`${data?.employee?.firstName?.slice(0, 1)} ${data?.employee?.lastName?.slice(0, 1)}`}
</span>
</div>
<div className={`d-flex align-items-center justify-content-start`}>
<p className={`mb-0 text-muted me-2`}>{fullName}</p>
<p className={`text-secondary m-0`} style={{ fontSize: "10px" }}>
{moment.utc(data?.commentDate).local().fromNow()}
</p>
</div>
</div>
<p className={`ms-6 text-start mb-0 text-body`}>{data?.comment}</p>
</li>
);
})}
</ul>
</div>
<div className="fw-bold my-2 text-start d-flex">
<span>Note:</span>
<div
className="fw-normal ms-2"
dangerouslySetInnerHTML={{ __html: commentsData?.description }}
/>
</div>
{commentsData?.reportedPreSignedUrls?.length > 0 && (
<div className=" text-start">
<p className="fw-bold m-0">Attachment</p>
<ImagePreview
IsReported={true}
images={commentsData?.reportedPreSignedUrls}
/>
</div>
)}
<form onSubmit={handleSubmit(onSubmit)} className="text-start">
<label className="fw-bold text-start my-1">Add comment :</label>
<textarea
{...register("comment")}
className="form-control"
id="exampleFormControlTextarea1"
placeholder="Enter comment"
/>
{errors.comment && (
<div className="danger-text">{errors.comment.message}</div>
)}
<div className="text-end my-1">
<button
type="button"
className="btn btn-sm btn-secondary"
onClick={closeModal}
data-bs-dismiss="modal"
>
Close
</button>
<button
type="submit"
className="btn btn-sm btn-primary ms-2"
disabled={loading}
>
{loading ? "Sending..." : "Comment"}
</button>
</div>
</form>
<ul
className="list-group px-0 mx-0 overflow-auto border-0"
ref={containerRef}
>
{comments &&
comments
?.slice()
.reverse()
.map((data, idx) => {
const fullName = `${data?.employee?.firstName} ${data?.employee?.lastName}`;
return (
<li
className={`list-group-item list-group-item-action border-none my-1 p-1`}
key={idx}
>
<div
className={`li-wrapper d-flex justify-content-start align-items-center my-0`}
>
<div className="avatar avatar-xs me-1">
<span
className={`avatar-initial rounded-circle bg-label-primary`}
>
{`${data?.employee?.firstName?.slice(
0,
1
)} ${data?.employee?.lastName?.slice(0, 1)}`}
</span>
</div>
<div
className={`d-flex align-items-center justify-content-start`}
>
<p className={`mb-0 text-muted me-2`}>{fullName}</p>
<p
className={`text-secondary m-0`}
style={{ fontSize: "10px" }}
>
{moment.utc(data?.commentDate).local().fromNow()}
</p>
</div>
</div>
<p className={`ms-6 text-start mb-0 text-body`}>
{data?.comment}
</p>
{data?.preSignedUrls?.length > 0 && (
<div className="ps-6 text-start">
<small className="">Attachment</small>
<ImagePreview
images={data?.preSignedUrls}
IsReported={true}
/>
</div>
)}
</li>
);
})}
</ul>
</div>
</div>
);

View File

@ -2,36 +2,48 @@ import React, { useState } from "react";
import LineChart from "../Charts/LineChart";
import { useProjects } from "../../hooks/useProjects";
import { useDashboard_Data } from "../../hooks/useDashboard_Data";
import {useSelector} from "react-redux";
import { useSelector } from "react-redux";
const ProjectProgressChart = () =>
{
const selectedProject = useSelector((store) => store.localVariables.projectId);
const ProjectProgressChart = () => {
const selectedProject = useSelector(
(store) => store.localVariables.projectId
);
const { projects } = useProjects();
// const [selectedProjectId, setSelectedProjectId] = useState("all");
const [range, setRange] = useState("1W");
const [range, setRange] = useState("15D");
const [showAllEmployees, setShowAllEmployees] = useState(false);
const getDaysFromRange = (range) => {
switch (range) {
case "1D": return 1;
case "1W": return 7;
case "15D": return 15;
case "1M": return 30;
case "3M": return 90;
case "1Y": return 365;
case "5Y": return 1825;
default: return 7;
case "1D":
return 1;
case "1W":
return 7;
case "15D":
return 15;
case "1M":
return 30;
case "3M":
return 90;
case "1Y":
return 365;
case "5Y":
return 1825;
default:
return 7;
}
};
const days = getDaysFromRange(range);
const today = new Date();
const FromDate = today.toLocaleDateString('en-CA');
const FromDate = today.toLocaleDateString("en-CA");
const projectId =
showAllEmployees || !selectedProject?.trim() ? null : selectedProject;
const { dashboard_data, loading: isLineChartLoading } = useDashboard_Data({
days,
FromDate,
projectId: selectedProject === " " ? "all" : selectedProject// selectedProjectId === "all" ? null : selectedProjectId,
projectId,
});
const sortedDashboardData = [...dashboard_data].sort(
@ -50,61 +62,69 @@ const ProjectProgressChart = () =>
];
const lineChartCategories = sortedDashboardData.map((d) =>
new Date(d.date).toLocaleDateString("en-US", { month: "short", day: "numeric" })
new Date(d.date).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
})
);
const lineChartCategoriesDates = sortedDashboardData.map((d) =>
new Date(d.date).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" })
new Date(d.date).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
})
);
const selectedProjectData = projects?.find((p) => p.id === selectedProject);
const selectedProjectName = selectedProjectData?.shortName?.trim()
? selectedProjectData.shortName
: selectedProjectData?.name;
return (
<div className="card h-100">
<div className="card-header">
{/* Row 1: Title + Project Selector */}
<div className="d-flex flex-wrap justify-content-between align-items-center mb-2">
<div className="card-title mb-0 text-start">
<div className="d-flex flex-wrap justify-content-between align-items-start mb-2">
{/* Left: Title */}
<div className="card-title text-start">
<h5 className="mb-1">Project Progress</h5>
<p className="card-subtitle">Progress Overview by Project</p>
</div>
{/* <div className="btn-group">
<button
className="btn btn-outline-primary btn-sm dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
{selectedProjectId === "all"
? "All Projects"
: projects?.find((p) => p.id === selectedProjectId)?.name || "Select Project"}
</button>
<ul className="dropdown-menu">
<li>
<button className="dropdown-item" onClick={() => setSelectedProjectId("all")}>
All Projects
</button>
</li>
{projects?.map((project) => (
<li key={project.id}>
<button
className="dropdown-item"
onClick={() => setSelectedProjectId(project.id)}
>
{project.name}
</button>
</li>
))}
</ul>
</div> */}
{/* Right: Checkbox and Project Name */}
<div className="d-flex flex-column align-items-start align-items-md-end text-start text-md-end mt-1 mt-md-0">
<div className="form-check form-switch mb-1 d-flex align-items-center">
<input
className="form-check-input"
type="checkbox"
role="switch"
id="showAllEmployees"
checked={showAllEmployees}
onChange={(e) => setShowAllEmployees(e.target.checked)}
/>
<label
className="form-check-label ms-2"
htmlFor="showAllEmployees"
>
All Projects
</label>
</div>
{!showAllEmployees && selectedProjectName && (
<p className="text-muted mb-0 small">
<span className="card-subtitle">{selectedProjectName}</span>
</p>
)}
</div>
</div>
{/* Row 2: Time Range Buttons */}
<div className="d-flex flex-wrap  mt-2">
<div className="d-flex flex-wrap mt-2">
{["1D", "1W", "15D", "1M", "3M", "1Y", "5Y"].map((key) => (
<button
key={key}
className={`border-0 bg-transparent px-2 py-1 text-sm rounded ${
range === key ? " border-bottom border-primary text-primary" : "text-muted"
range === key
? "border-bottom border-primary text-primary"
: "text-muted"
}`}
style={{ cursor: "pointer", transition: "all 0.2s ease" }}
onClick={() => setRange(key)}
@ -114,7 +134,8 @@ const ProjectProgressChart = () =>
))}
</div>
</div>
<div className="card-body ">
<div className="card-body">
<LineChart
seriesData={lineChartSeries}
categories={lineChartCategories}

View File

@ -10,7 +10,11 @@ import { changeMaster } from "../../slices/localVariablesSlice";
import { Link, useNavigate, useParams } from "react-router-dom";
import { formatDate } from "../../utils/dateUtils";
import { useEmployeeProfile } from "../../hooks/useEmployees";
import { cacheData, clearCacheKey, getCachedData } from "../../slices/apiDataManager";
import {
cacheData,
clearCacheKey,
getCachedData,
} from "../../slices/apiDataManager";
import { clearApiCacheKey } from "../../slices/apiCacheSlice";
const mobileNumberRegex = /^[0-9]\d{9}$/;
@ -178,7 +182,6 @@ const ManageEmployee = ({ employeeId, onClosed }) => {
clearCacheKey("allInactiveEmployeeList");
clearCacheKey("employeeProfile");
setLoading(false);
reset();
// navigation("/employees");
@ -238,10 +241,7 @@ const ManageEmployee = ({ employeeId, onClosed }) => {
{employee ? "Update Employee" : "Create Employee"}
</h6>
<span
className="cursor-pointer fs-6"
onClick={() => onClosed()}
>
<span className="cursor-pointer fs-6" onClick={() => onClosed()}>
<i className="bx bx-x"></i>
</span>
</div>
@ -509,11 +509,13 @@ const ManageEmployee = ({ employeeId, onClosed }) => {
<option disabled value="">
Select Role
</option>
{job_role?.map((item) => (
<option value={item?.id} key={item.id}>
{item?.name}{" "}
</option>
))}
{[...job_role]
.sort((a, b) => a?.name?.localeCompare(b.name))
.map((item) => (
<option value={item?.id} key={item.id}>
{item?.name}{" "}
</option>
))}
</select>
</div>
{errors.jobRoleId && (

View File

@ -177,17 +177,32 @@ const Header = () => {
</button>
{projectNames?.length > 1 && (
<ul className="dropdown-menu">
{projectNames?.map((project) => (
<li key={project?.id}>
<button
className="dropdown-item"
onClick={() => dispatch(setProjectId(project?.id))}
>
{project?.name}
</button>
</li>
))}
<ul
className="dropdown-menu"
style={{ overflow: "auto", maxHeight: "300px" }}
>
{[...projectNames]
.sort((a, b) => a.name.localeCompare(b.name))
.map((project) => (
<li key={project?.id}>
<button
className="dropdown-item"
onClick={() =>
dispatch(setProjectId(project?.id))
}
>
{project?.name}{" "}
{project?.shortName ? (
<span className="text-primary fw-semibold">
{" "}
({project?.shortName})
</span>
) : (
""
)}
</button>
</li>
))}
</ul>
)}
</div>
@ -200,7 +215,7 @@ const Header = () => {
<li className="nav-item dropdown-shortcuts navbar-dropdown dropdown me-2 me-xl-0">
<a
className="nav-link dropdown-toggle hide-arrow"
href="#;"
data-bs-toggle="dropdown"
data-bs-auto-close="true"
aria-expanded="false"
@ -309,7 +324,7 @@ const Header = () => {
</div>
</li>
<li className="nav-item dropdown-notifications navbar-dropdown dropdown me-2 me-xl-0">
{/* <li className="nav-item dropdown-notifications navbar-dropdown dropdown me-2 me-xl-0">
<a
className="nav-link dropdown-toggle hide-arrow cursor-pointer"
data-bs-toggle="dropdown"
@ -603,20 +618,7 @@ const Header = () => {
</div>
</li>
</ul>
{/* <div className="ps__rail-x" style="left: 0px; bottom: 0px;">
<div
className="ps__thumb-x"
tabindex="0"
style="left: 0px; width: 0px;"
></div>
</div>
<div className="ps__rail-y" style="top: 0px; right: 0px;">
<div
className="ps__thumb-y"
tabindex="0"
style="top: 0px; height: 0px;"
></div>
</div> */}
</li>
<li className="border-top">
<div className="d-grid p-4">
@ -628,7 +630,7 @@ const Header = () => {
</div>
</li>
</ul>
</li>
</li> */}
<li className="nav-item navbar-dropdown dropdown-user dropdown">
<a
aria-label="dropdown profile avatar"
@ -678,7 +680,7 @@ const Header = () => {
<span className="align-middle">My Profile</span>
</a>
</li>
<li>
<li onClick={handleProfilePage}>
<a
aria-label="go to setting "
className="dropdown-item cusor-pointer"
@ -687,7 +689,7 @@ const Header = () => {
<span className="align-middle">Settings</span>
</a>
</li>
<li>
{/* <li>
<a
aria-label="go to billing "
className="dropdown-item cusor-pointer"
@ -702,7 +704,7 @@ const Header = () => {
</span>
</span>
</a>
</li>
</li> */}
<li onClick={openChangePassword}>
{" "}
{/* Use the function from the context */}

View File

@ -273,7 +273,7 @@ const EditActivityModal = ({
activities
.slice()
.sort((a, b) =>
(a.activityName || "").localeCompare(
(a.activityName || "")?.localeCompare(
b.activityName || ""
)
)
@ -312,7 +312,7 @@ const EditActivityModal = ({
categories
.slice()
.sort((a, b) =>
(a.name || "").localeCompare(
(a.name || "")?.localeCompare(
b.name || ""
)
)

View File

@ -140,7 +140,7 @@ const FloorModel = ({
buildings
.filter((building) => building?.name)
.sort((a, b) =>
(a.name || "").localeCompare(b.name || "")
(a.name || "")?.localeCompare(b.name || "")
)
.map((building) => (
<option key={building.id} value={building.id}>
@ -172,7 +172,7 @@ const FloorModel = ({
[...selectedBuilding.floors]
.filter((floor) => floor?.floorName)
.sort((a, b) =>
(a.floorName || "").localeCompare(
(a.floorName || "")?.localeCompare(
b.floorName || ""
)
)

View File

@ -159,7 +159,7 @@ const TaskModel = ({
const newCategories = categories?.slice()?.sort((a, b) => {
const nameA = a?.name || "";
const nameB = b?.name || "";
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
});
setCategoryData(newCategories);
setSelectedCategory(newCategories[0])
@ -230,7 +230,7 @@ const TaskModel = ({
(floor) =>
floor?.floorName && Array.isArray(floor.workAreas)
)
?.sort((a, b) => a.floorName.localeCompare(b.floorName))
?.sort((a, b) => a.floorName?.localeCompare(b.floorName))
?.map((floor) => (
<option key={floor.id} value={floor.id}>
{floor.floorName} - ({floor.workAreas.length} Work
@ -263,7 +263,7 @@ const TaskModel = ({
<option value="0">Select Work Area</option>
{selectedFloor.workAreas
?.filter((workArea) => workArea?.areaName)
?.sort((a, b) => a.areaName.localeCompare(b.areaName))
?.sort((a, b) => a.areaName?.localeCompare(b.areaName))
?.map((workArea) => (
<option key={workArea.id} value={workArea.id}>
{workArea.areaName}
@ -299,7 +299,7 @@ const TaskModel = ({
?.sort((a, b) => {
const nameA = a?.activityName || "";
const nameB = b?.activityName || "";
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
})
?.map((activity) => (
<option key={activity.id} value={activity.id}>

View File

@ -197,7 +197,7 @@ const WorkAreaModel = ({
?.sort((a, b) => {
const nameA = a.floorName || "";
const nameB = b.floorName || "";
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
})
?.map((floor) => (
<option key={floor.id} value={floor.id}>
@ -231,7 +231,7 @@ const WorkAreaModel = ({
?.sort((a, b) => {
const nameA = a.areaName || "";
const nameB = b.areaName || "";
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
})
?.map((workArea) => (
<option key={workArea.id} value={workArea.id}>

View File

@ -0,0 +1,66 @@
import React, { useState } from "react";
import "./ImagePreviewstyle.css";
import GlobalModel from "./GlobalModel";
const ImagePreview = ({ images = [], IsReported = false }) => {
const [selectedImage, setSelectedImage] = useState(null);
const handleOpen = (imgSrc) => {
setSelectedImage(imgSrc);
};
const handleClose = () => {
setSelectedImage(null);
};
return (
<>
{IsReported ? (
<div className="d-flex flex-wrap gap-2">
{images.map((img, index) => (
<div
key={index}
className="img-container position-relative"
onClick={() => handleOpen(img)}
>
<img src={img} alt={`thumb-${index}`} className="img-thumbnail" />
<div className="eye-overlay d-flex justify-content-center align-items-center">
<i className="fa-solid fa-eye fs-6"></i>
</div>
</div>
))}
</div>
) : (
<div className="d-flex flex-wrap gap-2">
{images.map((img, index) => (
<div key={index} className="" onClick={() => handleOpen(img)}>
{/* <img src={img} alt={`thumb-${ index }`} className="img-thumbnail" /> */}
<i className="fa-regular fa-image fs-3 cursor-pointer"></i>
</div>
))}
</div>
)}
{selectedImage && (
<GlobalModel
isOpen={selectedImage}
size="md"
dialogClass="modal-dialog-centered"
closeModal={() => setSelectedImage(null)}
>
<div className="mt-3 img-preview" >
<img
src={selectedImage}
alt="Previe Image"
className="w-100"
/>
</div>
</GlobalModel>
)}
</>
);
};
export default ImagePreview;

View File

@ -0,0 +1,56 @@
.img-container {
width: 70px; /* or whatever size you want */
height: 30px;
position: relative; /* to contain the absolute overlay */
overflow: hidden;
cursor: pointer;
}
.img-container img.img-thumbnail {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
.eye-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.4);
opacity: 0;
transition: opacity 0.3s ease;
pointer-events: none;
color: white;
font-size: 1.5rem;
user-select: none;
}
/* center icon */
.eye-overlay i {
pointer-events: none;
}
/* fade in on hover */
.img-container:hover .eye-overlay {
opacity: 1;
pointer-events: auto; /* enable pointer events on hover */
}
.iconImage{
font-size: 30px;
}
.img-preview {
width: 100%;
text-align: center;
}
.img-preview img {
max-width: 100%;
max-height: 80vh;
object-fit: contain;
display: block;
margin: 0 auto;
}

View File

@ -5,7 +5,7 @@ import AttendanceRepository from "../repositories/AttendanceRepository";
export const useAttendace =(projectId)=>{
const [attendance, setAttendance] = useState([]);
const[loading,setLoading] = useState(false)
const[loading,setLoading] = useState(true)
const [error, setError] = useState(null);
const fetchData = () => {
@ -16,7 +16,8 @@ export const useAttendace =(projectId)=>{
AttendanceRepository.getAttendance(projectId)
.then((response) => {
setAttendance(response.data);
cacheData("Attendance", { data: response.data, projectId })
cacheData( "Attendance", {data: response.data, projectId} )
setLoading(false)
})
.catch((error) => {
setLoading(false)

View File

@ -143,7 +143,8 @@ export const useEmployeesAllOrByProjectId = (projectId, showInactive) => {
const [error, setError] = useState(null);
const fetchData = async (showInactive) => {
if (projectId) {
if ( projectId )
{
const Employees_cache = getCachedData("employeeListByProject");
if (!Employees_cache || Employees_cache.projectId !== projectId) {
setLoading(true);
@ -166,18 +167,11 @@ export const useEmployeesAllOrByProjectId = (projectId, showInactive) => {
setEmployees(Employees_cache.data);
setLoading(false);
}
} else {
} else
{
const cacheKey = showInactive
? "allInactiveEmployeeList"
: "allEmployeeList";
const employeesCache = getCachedData(cacheKey);
if (employeesCache) {
setEmployees(employeesCache.data);
setLoading(false);
} else {
setLoading(true);
setError(null);
try {
const response = await EmployeeRepository.getAllEmployeeList(
@ -190,7 +184,7 @@ export const useEmployeesAllOrByProjectId = (projectId, showInactive) => {
setError("Failed to fetch data.");
setLoading(false);
}
}
}
};

View File

@ -19,7 +19,7 @@ export const useProjects = () => {
const filterProjects = (projectsList) => {
return projectsList
.filter((proj) => projectIds.includes(String(proj.id)))
.sort((a, b) => a.name.localeCompare(b.name));
.sort((a, b) => a?.name?.localeCompare(b.name));
};
const projects_cache = getCachedData("projectslist");

View File

@ -9,7 +9,7 @@ import AttendanceLog from "../../components/Activities/AttendcesLogs";
import Attendance from "../../components/Activities/Attendance";
import AttendanceModel from "../../components/Activities/AttendanceModel";
import showToast from "../../services/toastService";
import { useProjects } from "../../hooks/useProjects";
// import { useProjects } from "../../hooks/useProjects";
import Regularization from "../../components/Activities/Regularization";
import { useAttendace } from "../../hooks/useAttendance";
import { useDispatch, useSelector } from "react-redux";
@ -22,7 +22,7 @@ import eventBus from "../../services/eventBus";
const AttendancePage = () => {
const [activeTab, setActiveTab] = useState("all");
const [showOnlyCheckout, setShowOnlyCheckout] = useState(false);
const [ShowPending, setShowPending] = useState(false);
const loginUser = getCachedProfileData();
var selectedProject = useSelector((store) => store.localVariables.projectId);
const { projects, loading: projectLoading } = useProjects();
@ -122,11 +122,11 @@ const AttendancePage = () => {
setAttendances(attendance);
}, [attendance]);
useEffect(() => {
if (selectedProject === 1 || selectedProject === undefined) {
dispatch(setProjectId(loginUser?.projects[0]));
}
}, [selectedProject, loginUser?.projects]);
// useEffect(() => {
// if (selectedProject === 1 || selectedProject === undefined) {
// dispatch(setProjectId(loginUser?.projects[0]));
// }
// }, [selectedProject, loginUser?.projects]);
// Filter attendance data based on the toggle
// const filteredAttendance = showOnlyCheckout
@ -134,8 +134,8 @@ const AttendancePage = () => {
// (att) => att?.checkOutTime !== null && att?.checkInTime !== null
// )
// : attendances;
const filteredAttendance = showOnlyCheckout
? attendances?.filter((att) => att?.checkOutTime === null)
const filteredAttendance = ShowPending
? attendances?.filter((att) => att?.checkInTime !== null && att?.checkOutTime === null)
: attendances;
useEffect(() => {
@ -242,21 +242,23 @@ const AttendancePage = () => {
</li>
</ul>
<div className="tab-content attedanceTabs py-0 px-1 px-sm-3">
{projectLoading && <span>Loading..</span>}
{!projectLoading && !attendances && <span>Not Found</span>}
{activeTab === "all" && (
<>
{!projectLoading && filteredAttendance?.length === 0 && (
<p>No Employee assigned yet.</p>
)}
<div className="tab-pane fade show active py-0">
<Attendance
attendance={filteredAttendance}
handleModalData={handleModalData}
getRole={getRole}
setshowOnlyCheckout={setShowPending}
showOnlyCheckout={ShowPending}
/>
</div>
{!attLoading && filteredAttendance?.length === 0 && (
<p> {ShowPending ? "No Pending Available" : "No Employee assigned yet."} </p>
)}
</>
)}
@ -265,7 +267,8 @@ const AttendancePage = () => {
<AttendanceLog
handleModalData={handleModalData}
projectId={selectedProject}
showOnlyCheckout={showOnlyCheckout}
setshowOnlyCheckout={setShowPending}
showOnlyCheckout={ShowPending}
/>
</div>
)}
@ -275,6 +278,9 @@ const AttendancePage = () => {
<Regularization handleRequest={handleSubmit} />
</div>
)}
{attLoading && <span>Loading..</span>}
{!attLoading && !attendances && <span>Not Found</span>}
</div>
</div>
</div>

View File

@ -10,6 +10,7 @@ import DateRangePicker from "../../components/common/DateRangePicker";
import { useSearchParams } from "react-router-dom";
import moment from "moment";
import FilterIcon from "../../components/common/FilterIcon"; // Import the FilterIcon component
import GlobalModel from "../../components/common/GlobalModel";
const DailyTask = () => {
const [searchParams] = useSearchParams();
@ -170,19 +171,14 @@ const DailyTask = () => {
</div>
<div
className={`modal fade ${isModalOpenComment ? "show d-block" : ""}`}
tabIndex="-1"
role="dialog"
style={{ display: isModalOpenComment ? "block" : "none" }}
aria-hidden={!isModalOpenComment}
>
<ReportTaskComments
{isModalOpenComment && (
<GlobalModel isOpen={isModalOpenComment} size="lg" closeModal={()=>setIsModalOpenComment(false)}>
<ReportTaskComments
commentsData={comments}
closeModal={closeCommentModal}
/>
</div>
</GlobalModel>
)}
<div className="container-xxl flex-grow-1 container-p-y">
<Breadcrumb

View File

@ -181,7 +181,7 @@ const Directory = ({ IsPage = true, prefernceContacts }) => {
(c.bucketIds || []).some((id) => selectedBucketIds.includes(id));
return matchesSearch && matchesCategory && matchesBucket;
}).sort((a, b) => a.name.localeCompare(b.name));
}).sort((a, b) => a?.name?.localeCompare(b.name));
}, [
ContactList,
searchText,

View File

@ -42,7 +42,7 @@ const AttendancesEmployeeRecords = ({ employee }) => {
const sortByName = (a, b) => {
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
};
const group1 = data

View File

@ -9,7 +9,7 @@ import { useEmployeesAllOrByProjectId } from "../../hooks/useEmployees";
import { useProjects } from "../../hooks/useProjects";
import { useProfile } from "../../hooks/useProfile";
import { hasUserPermission } from "../../utils/authUtils";
import { MANAGE_EMPLOYEES } from "../../utils/constants";
import { ITEMS_PER_PAGE, MANAGE_EMPLOYEES } from "../../utils/constants";
import { clearCacheKey } from "../../slices/apiDataManager";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
import SuspendEmp from "../../components/Employee/SuspendEmp";
@ -29,10 +29,9 @@ const EmployeeList = () => {
const [selectedProject, setSelectedProject] = useState(() => selectedProjectId || "");
const { projects, loading: projectLoading } = useProjects();
const [showInactive, setShowInactive] = useState(false);
const [showAllEmployees, setShowAllEmployees] = useState(false); // New state for "All Employee"
const [showAllEmployees, setShowAllEmployees] = useState(false);
const Manage_Employee = useHasUserPermission(MANAGE_EMPLOYEES);
// Modify the hook to conditionally pass selectedProject or null based on showAllEmployees
const { employees, loading, setLoading, error, recallEmployeeData } =
useEmployeesAllOrByProjectId(showAllEmployees ? null : selectedProject, showInactive);
const [projectsList, setProjectsList] = useState(projects || []);
@ -40,7 +39,7 @@ const EmployeeList = () => {
const [employeeList, setEmployeeList] = useState([]);
const [modelConfig, setModelConfig] = useState();
const [currentPage, setCurrentPage] = useState(1);
const [itemsPerPage] = useState(15);
const [itemsPerPage] = useState(ITEMS_PER_PAGE);
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [isEmployeeModalOpen, setIsEmployeeModalOpen] = useState(false);
const [searchText, setSearchText] = useState("");
@ -61,7 +60,16 @@ const EmployeeList = () => {
const results = employeeList.filter((item) => {
const fullName = `${item.firstName} ${item.lastName}`.toLowerCase();
return fullName.includes(value);
const email = item.email ? item.email.toLowerCase() : "";
const phoneNumber = item.phoneNumber ? item.phoneNumber.toLowerCase() : "";
const jobRole = item.jobRole ? item.jobRole.toLowerCase() : ""; // Get jobRole and convert to lowercase
return (
fullName.includes(value) ||
email.includes(value) ||
phoneNumber.includes(value) ||
jobRole.includes(value) // Include jobRole in the search
);
});
setFilteredData(results);
@ -77,7 +85,7 @@ const EmployeeList = () => {
}`.toLowerCase();
const nameB = `${b.firstName || ""}${b.middleName || ""}${b.lastName || ""
}`.toLowerCase();
return nameA.localeCompare(nameB);
return nameA?.localeCompare(nameB);
});
setEmployeeList(sorted);
@ -180,12 +188,11 @@ const EmployeeList = () => {
recallEmployeeData(e.target.checked);
};
// New handler for "All Employee" toggle
const handleAllEmployeesToggle = (e) => {
const isChecked = e.target.checked;
setShowAllEmployees(isChecked);
// If "All Employees" is checked, we don't want to filter by project,
// so we pass null for selected project. Otherwise, use the currently selected project.
setShowInactive(false)
setShowAllEmployees( isChecked );
recallEmployeeData(showInactive, isChecked ? null : selectedProject);
};
@ -203,7 +210,6 @@ const EmployeeList = () => {
const handleProjectSelection = (e) => {
const newProjectId = e.target.value;
setSelectedProject(newProjectId);
// If a specific project is selected, uncheck "All Employees"
if (newProjectId) {
setShowAllEmployees(false);
}
@ -279,128 +285,109 @@ const EmployeeList = () => {
className="dataTables_wrapper dt-bootstrap5 no-footer"
style={{ width: "98%" }}
>
<div className="row mb-2 ">
<div className="col-md-3 col-sm-6 ">
<div className="form-check text-start">
<div className="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-3">
{/* Switches: All Employees + Inactive */}
<div className="d-flex flex-wrap align-items-center gap-3">
{/* All Employees Switch */}
<div className="form-check form-switch text-start">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="allEmployeesCheckbox"
checked={showAllEmployees}
onChange={handleAllEmployeesToggle}
/>
<label className="form-check-label" htmlFor="allEmployeesCheckbox">
<label className="form-check-label ms-0" htmlFor="allEmployeesCheckbox">
All Employees
</label>
</div>
</div>
<div className="col-md-9 col-sm-6">
<div className="dt-action-buttons text-xl-end text-lg-start text-md-end text-start d-flex align-items-center justify-content-sm-end justify-content-between gap-2 flex-md-row flex-sm-column mb-3 mb-md-0 mt-1 mt-md-0 gap-md-4">
<div
id="DataTables_Table_0_filter"
className="dataTables_filter"
>
<label>
<input
type="search"
value={searchText}
onChange={handleSearch}
className="form-control form-control-sm"
placeholder="Search User"
aria-controls="DataTables_Table_0"
></input>
{/* Show Inactive Employees Switch */}
{showAllEmployees && (
<div className="form-check form-switch text-start">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showInactive}
onChange={handleToggle}
/>
<label className="form-check-label ms-0" htmlFor="inactiveEmployeesCheckbox">
Show Inactive Employees
</label>
</div>
<div className="dt-buttons btn-group flex-wrap">
{" "}
<div className=" d-flex justify-contend-end">
<button
aria-label="Click me"
className="btn btn-sm btn-label-secondary me-4 dropdown-toggle "
type="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
<i className="bx bx-export me-2 bx-sm"></i>Export
</button>
<ul className="dropdown-menu">
<li>
<a
className="dropdown-item"
href="#"
onClick={() => handleExport("print")}
>
<i className="bx bx-printer me-1"></i> Print
</a>
</li>
<li>
<a
className="dropdown-item"
href="#"
onClick={() => handleExport("csv")}
>
<i className="bx bx-file me-1"></i> CSV
</a>
</li>
<li>
<a
className="dropdown-item"
href="#"
onClick={() => handleExport("excel")}
>
<i className="bx bxs-file-export me-1"></i>{" "}
Excel
</a>
</li>
<li>
<a
className="dropdown-item"
href="#"
onClick={() => handleExport("pdf")}
>
<i className="bx bxs-file-pdf me-1"></i> PDF
</a>
</li>
</ul>
<button
className={`btn btn-sm add-new btn-primary ${!Manage_Employee && "d-none"
}`}
tabIndex="0"
type="button"
onClick={() => {
handleEmployeeModel(null);
}}
>
<span>
<i className="bx bx-plus-circle me-2"></i>
<span className="d-none d-md-inline-block">
Add New Employee
</span>
</span>
</button>{" "}
</div>
</div>
</div>
)}
</div>
</div>
<div className="d-flex justify-content-end mb-2">
{/* Show Inactive Employees Checkbox */}
<div className={`${showAllEmployees ? '' : selectedProject ? 'd-none' : ''}`}>
<div className="form-check">
<input
type="checkbox"
className="form-check-input"
id="inactiveEmployeesCheckbox"
checked={showInactive}
onChange={handleToggle}
/>
<label className="form-check-label" htmlFor="inactiveEmployeesCheckbox">
Show Inactive Employees
{/* Right side: Search + Export + Add Employee */}
<div className="d-flex flex-wrap align-items-center justify-content-end gap-3 flex-grow-1">
{/* Search */}
<div className="dataTables_filter">
<label className="mb-0">
<input
type="search"
value={searchText}
onChange={handleSearch}
className="form-control form-control-sm"
placeholder="Search User"
aria-controls="DataTables_Table_0"
/>
</label>
</div>
{/* Export Dropdown */}
<div className="dropdown">
<button
aria-label="Click me"
className="btn btn-sm btn-label-secondary dropdown-toggle"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
<i className="bx bx-export me-2 bx-sm"></i>Export
</button>
<ul className="dropdown-menu">
<li>
<a className="dropdown-item" href="#" onClick={() => handleExport("print")}>
<i className="bx bx-printer me-1"></i> Print
</a>
</li>
<li>
<a className="dropdown-item" href="#" onClick={() => handleExport("csv")}>
<i className="bx bx-file me-1"></i> CSV
</a>
</li>
<li>
<a className="dropdown-item" href="#" onClick={() => handleExport("excel")}>
<i className="bx bxs-file-export me-1"></i> Excel
</a>
</li>
<li>
<a className="dropdown-item" href="#" onClick={() => handleExport("pdf")}>
<i className="bx bxs-file-pdf me-1"></i> PDF
</a>
</li>
</ul>
</div>
{/* Add Employee */}
{Manage_Employee && (
<button
className="btn btn-sm btn-primary"
type="button"
onClick={() => handleEmployeeModel(null)}
>
<i className="bx bx-plus-circle me-2"></i>
<span className="d-none d-md-inline-block">Add New Employee</span>
</button>
)}
</div>
</div>
<table
className="datatables-users table border-top dataTable no-footer dtr-column text-nowrap"
id="DataTables_Table_0"
@ -572,7 +559,7 @@ const EmployeeList = () => {
</td>
<td className=" d-none d-md-table-cell">
{moment(item.joiningDate).format("DD-MMM-YYYY")}
{moment(item.joiningDate)?.format("DD-MMM-YYYY")}
</td>
<td>
{showInactive ? (

View File

@ -34,7 +34,7 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => {
if (!sortKey) return 0;
const aValue = a[sortKey] || "";
const bValue = b[sortKey] || "";
return aValue.localeCompare(bValue);
return aValue?.localeCompare(bValue);
});
// Pagination logic

View File

@ -52,7 +52,7 @@ const ProjectList = () => {
.filter((statusId) => grouped[statusId])
.flatMap((statusId) =>
grouped[statusId].sort((a, b) =>
a.name.toLowerCase().localeCompare(b.name.toLowerCase())
a.name.toLowerCase()?.localeCompare(b.name.toLowerCase())
)
);
setProjectList(sortedGrouped);