Compare commits

..

No commits in common. "d48c6fd7e36c8f291cc30de7cbae373c5ec86908" and "6e60c6568e4b9ad92cebf2c706622be97144de5e" have entirely different histories.

8 changed files with 115 additions and 194 deletions

View File

@ -1,155 +1,80 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from 'react'
import { useEmployeeAttendacesLog } from "../../hooks/useAttendance"; import { useEmployeeAttendacesLog } from '../../hooks/useAttendance';
import { convertShortTime } from "../../utils/dateUtils"; import { convertShortTime } from '../../utils/dateUtils';
import { useNavigate } from "react-router-dom";
const AttendLogs = ({ Id }) => { const AttendLogs = ({ Id }) => {
const { logs, loading } = useEmployeeAttendacesLog(Id);
const navigate = useNavigate();
const whichActivityPerform = (actvity) => { const {logs, loading} = useEmployeeAttendacesLog( Id )
const whichActivityPerform = ( actvity ) =>
{
switch (actvity) { switch (actvity) {
case 1: case 1:
return ( return "IN"
<i
className="bx bx-right-arrow-circle text-success"
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip"
title="Check-In"
></i>
);
break; break;
case 2: case 2:
return ( return "Requested"
<i
className="bx bx-help-circle text-secondary"
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip"
title="regularize Requested"
></i>
);
break; break;
case 3: case 3:
return ( return "Deleted"
<i
className="bx bx-x-circle text-danger"
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip"
title="Request Rejected"
></i>
);
break; break;
case 4: case 4:
return ( return "OUT"
<i
className="bx bx-left-arrow-circle text-danger "
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip"
title="Check-Out"
></i>
);
break;
case 5:
return (
<i
className="bx bx-check-circle text-success"
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip"
title="Regularized"
></i>
);
break; break;
case 5:
return "Regularized"
break;
default: default:
break; break;
} }
}; }
const LocationLink = (lat, lng) => {
const url = `https://www.google.com/maps?q=${lat},${lng}`;
window.open(url, "_blank"); // Open in new tab
};
useEffect(() => {
const tooltipTriggerList = Array.from(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
);
tooltipTriggerList.forEach((el) => new bootstrap.Tooltip(el));
}, []);
return ( return (
<div className="table-responsive"> <div className="table-responsive">
<div className="text-start"> {loading && <p>Loading..</p>}
{logs && !loading && ( { logs && logs.length > 0 && (
<p>
Attendance for{" "}
{logs[0]?.employee?.firstName + " " + logs[0]?.employee?.lastName}{" "}
on {logs[0]?.activityTime.slice(0, 10)}{" "}
</p>
)}
</div>
{loading && <p>Loading..</p>}
{logs && logs.length > 0 && (
<> <>
<div className="d-flex justify-content-start align-items-center gap-2 my-1"> <div className="d-flex justify-content-start align-items-center gap-2 my-1">
<div className="align-item-center"></div> <div className="align-item-center">
</div> <p className="p-0 m-0">Date : {logs[0].activityTime.slice(0,10)} </p>
</div>
</div>
<table className="table table-sm mb-0"> <table className="table table-sm mb-0">
<thead> <thead>
<tr> <tr>
<th style={{ width: "20%" }}>Date</th> <th style={{width: '15%'}}>Time</th>
<th style={{ width: "15%" }}>Time</th> <th style={{ width: '20%' }}>Activity</th>
<th style={{ width: "20%" }}>Activity</th> <th style={{ width: '20%' }}>Date</th>
<th style={{ width: "20%" }}>Location</th> <th style={{ width: '45%' }}>Description</th>
<th style={{ width: "45%" }}>Description</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody>
{logs {logs
.slice() .slice()
.sort((a, b) => b.id - a.id) .sort((a, b) => b.id - a.id)
.map((log, index) => ( .map((log, index) => (
<tr key={index}> <tr key={index}>
<td>{log.activityTime.slice(0, 10)}</td> <td>{convertShortTime( log.activityTime )}</td>
<td>{convertShortTime(log.activityTime)}</td>
<td>{whichActivityPerform(log.activity)}</td> <td>{whichActivityPerform(log.activity)}</td>
<td> <td>{log.activityTime.slice(0, 10)}</td>
{log?.latitude != 0 ? (
<i
class="bx bx-location-plus text-warning cursor-pointer"
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip"
title="Location"
onClick={() =>
LocationLink(log?.latitude, log?.longitude)
}
></i>
) : (
"--"
)}
</td>
<td className="text-wrap" colSpan={3}> <td className="text-wrap" colSpan={3}>
{log?.comment} {log?.comment}
</td> </td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
</> </>
)} )
}
</div> </div>
); );
}; };
export default AttendLogs; export default AttendLogs;

View File

@ -65,8 +65,7 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
}) })
); );
} }
}, [ dateRange, projectId, isRefreshing ] ); }, [dateRange, projectId, isRefreshing]);
return ( return (
<> <>
@ -83,13 +82,12 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
loading ? "spin":"" loading ? "spin":""
}`} }`}
title="Refresh" title="Refresh"
onClick={() => setIsRefreshing( !isRefreshing )} onClick={()=>setIsRefreshing(!isRefreshing)}
/> />
</div> </div>
</div> </div>
<div className="table-responsive text-nowrap"> <div className="table-responsive text-nowrap">
{(data && data.length > 0 ) && ( {data && data.length > 0 ? (
<table className="table mb-0"> <table className="table mb-0">
<thead> <thead>
<tr> <tr>
@ -109,7 +107,14 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
</thead> </thead>
<tbody> <tbody>
{loading && <td colSpan={5}>Loading...</td>} {loading && <td colSpan={5}>Loading...</td>}
{currentItems?.map( ( attendance, index ) => ( {error && <td colSpan={5}>{error}</td>}
{data && data.length === 0 && (
<tr>
<td colSpan={5}>No Data Found</td>
</tr>
)}
{currentItems?.map((attendance, index) => (
<tr key={index}> <tr key={index}>
<td colSpan={2}> <td colSpan={2}>
<div className="d-flex justify-content-start align-items-center"> <div className="d-flex justify-content-start align-items-center">
@ -128,12 +133,12 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
</td> </td>
<td> <td>
{" "} {" "}
{moment( attendance.checkInTime ).format( "DD-MMM-YYYY" )} {moment(attendance.checkInTime).format("DD-MMM-YYYY")}
</td> </td>
<td>{convertShortTime( attendance.checkInTime )}</td> <td>{convertShortTime(attendance.checkInTime)}</td>
<td> <td>
{attendance.checkOutTime {attendance.checkOutTime
? convertShortTime( attendance.checkOutTime ) ? convertShortTime(attendance.checkOutTime)
: "--"} : "--"}
</td> </td>
<td className="text-center"> <td className="text-center">
@ -145,14 +150,12 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
/> />
</td> </td>
</tr> </tr>
) )} ))}
</tbody> </tbody>
</table> </table>
) } ) : (
{(!loading && data.length === 0) &&
<span>No employee logs</span> <span>No employee logs</span>
} )}
{error && <td colSpan={5}>{error}</td>}
</div> </div>
{!loading && ( {!loading && (
<nav aria-label="Page "> <nav aria-label="Page ">
@ -198,7 +201,7 @@ const AttendanceLog = ({ handleModalData, projectId }) => {
</li> </li>
</ul> </ul>
</nav> </nav>
)} )}
</> </>
); );
}; };

View File

@ -141,9 +141,7 @@ const EditActivityModal = ({
data: newProject, data: newProject,
}); });
resetForm(); resetForm();
dispatch( refreshData( true ) ); dispatch(refreshData(true));
showToast("Activity Updated Successfully","success")
onClose(); onClose();
} }
}) })

View File

@ -16,8 +16,7 @@ export const useAllEmployees = () => {
setLoading(true); setLoading(true);
const response = await EmployeeRepository.getAllEmployeeList(); const response = await EmployeeRepository.getAllEmployeeList();
cacheData("AllEmployees", response.data); cacheData("AllEmployees", response.data);
setEmployeeList( response.data ); setEmployeeList(response.data);
setLoading(false);
} else { } else {
setEmployeeList(EmployeeList_cached); setEmployeeList(EmployeeList_cached);
setLoading(false); setLoading(false);

View File

@ -93,14 +93,12 @@ const AttendancePage = () => {
}, [modelConfig, isCreateModalOpen]); }, [modelConfig, isCreateModalOpen]);
useEffect(() => { useEffect(() => {
setAttendances(attendance); setAttendances(attendance);
}, [ attendance ] ); }, [attendance]);
useEffect(()=>{
if(selectedProject == 1){
useEffect(() => { dispatch(setProjectId(loginUser?.projects[0]))
if (selectedProject === 1 || selectedProject === undefined ) { }
dispatch(setProjectId(loginUser?.projects[0])); },[selectedProject,loginUser?.projects])
}
}, [selectedProject, loginUser?.projects]);
return ( return (
<> <>
{isCreateModalOpen && modelConfig && ( {isCreateModalOpen && modelConfig && (
@ -160,6 +158,7 @@ const AttendancePage = () => {
</select> </select>
</label> </label>
)} )}
</div> </div>
</ul> </ul>
<ul className="nav nav-tabs" role="tablist"> <ul className="nav nav-tabs" role="tablist">
@ -204,18 +203,13 @@ const AttendancePage = () => {
{!projectLoading && !attendances && <span>Not Found</span>} {!projectLoading && !attendances && <span>Not Found</span>}
{activeTab === "all" && ( {activeTab === "all" && (
<> <div className="tab-pane fade show active py-0">
{!projectLoading && attendances.length === 0 && ( <Attendance
<p>No Employee assigned yet.</p> attendance={attendances}
)} handleModalData={handleModalData}
<div className="tab-pane fade show active py-0"> getRole={getRole}
<Attendance />
attendance={attendances} </div>
handleModalData={handleModalData}
getRole={getRole}
/>
</div>
</>
)} )}
{activeTab === "logs" && ( {activeTab === "logs" && (

View File

@ -32,7 +32,9 @@ const DailyTask = () => {
// Sync projectId (either from URL or pick first accessible one) // Sync projectId (either from URL or pick first accessible one)
useEffect(() => { useEffect(() => {
if (!project_lodaing && projects.length > 0 && !initialized) { if (!project_lodaing && projects.length > 0 && !initialized) {
if (selectedProject === 1 || selectedProject === undefined) { if (projectId) {
dispatch(setProjectId(projectId));
} else if (!selectedProject) {
dispatch(setProjectId(projects[0].id)); dispatch(setProjectId(projects[0].id));
} }
@ -75,6 +77,7 @@ const DailyTask = () => {
selectTask(task); selectTask(task);
openModal(); openModal();
}; };
return ( return (
<> <>
<div <div
@ -157,20 +160,7 @@ const DailyTask = () => {
</tr> </tr>
</thead> </thead>
<tbody className="table-border-bottom-0"> <tbody className="table-border-bottom-0">
{TaskLists?.length === 0 && !task_loading && (
{task_loading && (
<tr>
<td colSpan={7} className="text-center">
<p>Loading..</p>
</td>
</tr>
)}
{project_lodaing && <tr>
<td colSpan={7} className="text-center">
Loading...
</td>
</tr>}
{TaskLists?.length === 0 && !task_loading && !project_lodaing &&(
<tr> <tr>
<td colSpan={7} className="text-center"> <td colSpan={7} className="text-center">
No Task Found No Task Found
@ -178,6 +168,14 @@ const DailyTask = () => {
</tr> </tr>
)} )}
{task_loading && (
<tr>
<td colSpan={7} className="text-center">
<p>Loading..</p>
</td>
</tr>
)}
{TaskLists.map((task, index) => { {TaskLists.map((task, index) => {
return ( return (
<React.Fragment key={index}> <React.Fragment key={index}>

View File

@ -84,7 +84,7 @@ const AttendancesEmployeeRecords = ({ employee }) => {
}) })
); );
} }
}, [dateRange, employee,isRefreshing]); }, [dateRange, employee]);
const openModal = (id) => { const openModal = (id) => {
setAttendanecId(id); setAttendanecId(id);
@ -132,20 +132,14 @@ const AttendancesEmployeeRecords = ({ employee }) => {
<i <i
className={`bx bx-refresh cursor-pointer fs-4 ${ className={`bx bx-refresh cursor-pointer fs-4 ${
loading ? "spin" : "" loading ? "spin" : ""
}`} }`}
data-toggle="tooltip"
title="Refresh" title="Refresh"
onClick={() => setIsRefreshing(!isRefreshing)} onClick={() => setIsRefreshing(!isRefreshing)}
/> />
</div> </div>
</div> </div>
<div className="table-responsive text-nowrap"> <div className="table-responsive text-nowrap">
{(!loading && data.length === 0) && {data && data.length > 0 ? (
<span>No employee logs</span>
}
{error && <div className="text-center">{error }</div>}
{(loading && !data ) && <div className="text-center">Loading...</div>}
{(data && data.length > 0 ) && (
<table className="table mb-0"> <table className="table mb-0">
<thead> <thead>
<tr> <tr>
@ -165,7 +159,15 @@ const AttendancesEmployeeRecords = ({ employee }) => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{currentItems?.map( ( attendance, index ) => ( {loading && <td colSpan={5}>Loading...</td>}
{error && <td colSpan={5}>{error}</td>}
{data && data.length === 0 && (
<tr>
<td colSpan={5}>No Data Found</td>
</tr>
)}
{currentItems?.map((attendance, index) => (
<tr key={index}> <tr key={index}>
<td colSpan={2}> <td colSpan={2}>
<div className="d-flex justify-content-start align-items-center"> <div className="d-flex justify-content-start align-items-center">
@ -184,12 +186,12 @@ const AttendancesEmployeeRecords = ({ employee }) => {
</td> </td>
<td> <td>
{" "} {" "}
{moment( attendance.checkInTime ).format( "DD-MMM-YYYY" )} {moment(attendance.checkInTime).format("DD-MMM-YYYY")}
</td> </td>
<td>{convertShortTime( attendance.checkInTime )}</td> <td>{convertShortTime(attendance.checkInTime)}</td>
<td> <td>
{attendance.checkOutTime {attendance.checkOutTime
? convertShortTime( attendance.checkOutTime ) ? convertShortTime(attendance.checkOutTime)
: "--"} : "--"}
</td> </td>
@ -200,18 +202,20 @@ const AttendancesEmployeeRecords = ({ employee }) => {
tabIndex="0" tabIndex="0"
aria-controls="DataTables_Table_0" aria-controls="DataTables_Table_0"
data-bs-toggle="modal" data-bs-toggle="modal"
onClick={() => openModal( attendance.id )} onClick={() => openModal(attendance.id)}
> >
View View
</button> </button>
</td> </td>
</tr> </tr>
) )} ))}
</tbody> </tbody>
</table> </table>
) } ) : (
<span>No employee logs</span>
)}
</div> </div>
{(!loading && data.length > 5) && ( {!loading && (
<nav aria-label="Page "> <nav aria-label="Page ">
<ul className="pagination pagination-sm justify-content-end py-1"> <ul className="pagination pagination-sm justify-content-end py-1">
<li <li

View File

@ -143,7 +143,7 @@ const MasterTable = ({ data, columns, loading, handleModalData }) => {
)} )}
{/* Pagination */} {/* Pagination */}
{!loading && safeData.length > 20 && ( {!loading && (
<nav aria-label="Page "> <nav aria-label="Page ">
<ul className="pagination pagination-sm justify-content-end py-1"> <ul className="pagination pagination-sm justify-content-end py-1">
<li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}> <li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>