Compare commits
4 Commits
1e57e6fc03
...
7d3bffe0cd
Author | SHA1 | Date | |
---|---|---|---|
7d3bffe0cd | |||
![]() |
7d07002555 | ||
![]() |
2ebd1a074f | ||
![]() |
ce4b517ce5 |
@ -266,7 +266,7 @@ const WorkItem = ({
|
||||
></i>
|
||||
|
||||
<ul className="dropdown-menu dropdown-menu-start">
|
||||
{!projectId && ManageTasks && PlannedWork !== CompletedWork && (
|
||||
{!projectId && ManageAndAssignTak && PlannedWork !== CompletedWork && (
|
||||
<li>
|
||||
<a
|
||||
className="dropdown-item d-flex align-items-center"
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { timeElapsed } from '../utils/dateUtils';
|
||||
import { useSelector } from 'react-redux';
|
||||
import {THRESH_HOLD} from '../utils/constants';
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { timeElapsed } from "../utils/dateUtils";
|
||||
import { useSelector } from "react-redux";
|
||||
import { THRESH_HOLD } from "../utils/constants";
|
||||
|
||||
export const ACTIONS = {
|
||||
CHECK_IN: 0,
|
||||
@ -10,124 +9,143 @@ export const ACTIONS = {
|
||||
REGULARIZATION: 2,
|
||||
REQUESTED: 3,
|
||||
APPROVED: 4,
|
||||
REJECTED: 5
|
||||
REJECTED: 5,
|
||||
};
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const useAttendanceStatus = (attendanceData) => {
|
||||
|
||||
const [status, setStatus] = useState({
|
||||
status: "Unknown",
|
||||
action: null,
|
||||
disabled: true,
|
||||
text: "Unknown",
|
||||
color: 'btn-secondary',
|
||||
color: "btn-secondary",
|
||||
});
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const { checkInTime, checkOutTime, activity } = attendanceData;
|
||||
|
||||
|
||||
if(activity === 0 && checkInTime === null && checkOutTime === null){
|
||||
if (activity === 0 && checkInTime === null && checkOutTime === null) {
|
||||
setStatus({
|
||||
status: "Check-In",
|
||||
action: ACTIONS.CHECK_IN,
|
||||
disabled: false,
|
||||
text: "Check In",
|
||||
color: 'btn-primary',
|
||||
})
|
||||
}else if(activity === 0&& checkInTime === null && checkOutTime === null && !timeElapsed(checkInTime,THRESH_HOLD)){
|
||||
color: "btn-primary",
|
||||
});
|
||||
} else if (activity === 4 && new Date(checkOutTime) < now) {
|
||||
setStatus({
|
||||
status: "Approved",
|
||||
action: ACTIONS.APPROVED,
|
||||
disabled: true,
|
||||
text: "Approved",
|
||||
color: "btn-success",
|
||||
});
|
||||
} else if (
|
||||
activity === 0 &&
|
||||
checkInTime === null &&
|
||||
checkOutTime === null &&
|
||||
!timeElapsed(checkInTime, THRESH_HOLD)
|
||||
) {
|
||||
setStatus({
|
||||
status: "Check-In",
|
||||
action: ACTIONS.CHECK_IN,
|
||||
disabled: false,
|
||||
text: "Check In",
|
||||
color: 'btn-primary',
|
||||
})
|
||||
|
||||
} else if(activity === 0&& checkInTime !== null && checkOutTime === null && timeElapsed(checkInTime,THRESH_HOLD)){
|
||||
color: "btn-primary",
|
||||
});
|
||||
} else if (
|
||||
activity === 0 &&
|
||||
checkInTime !== null &&
|
||||
checkOutTime === null &&
|
||||
timeElapsed(checkInTime, THRESH_HOLD)
|
||||
) {
|
||||
setStatus({
|
||||
status: "Request Regularize",
|
||||
action: ACTIONS.REGULARIZATION,
|
||||
disabled: false,
|
||||
text: "Regularizes",
|
||||
color: 'btn-warning',
|
||||
color: "btn-warning",
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
else if(activity === 1 && checkInTime !== null && checkOutTime === null && !timeElapsed(checkInTime,THRESH_HOLD)){
|
||||
} else if (
|
||||
activity === 1 &&
|
||||
checkInTime !== null &&
|
||||
checkOutTime === null &&
|
||||
!timeElapsed(checkInTime, THRESH_HOLD)
|
||||
) {
|
||||
setStatus({
|
||||
status: "Check-Out",
|
||||
action: ACTIONS.CHECK_OUT,
|
||||
disabled: false,
|
||||
text: "Check Out",
|
||||
color: 'btn-primary',
|
||||
color: "btn-primary",
|
||||
});
|
||||
}else if(activity === 1 && checkInTime !== null && checkOutTime === null && timeElapsed(checkInTime,THRESH_HOLD)){
|
||||
} else if (
|
||||
activity === 1 &&
|
||||
checkInTime !== null &&
|
||||
checkOutTime === null &&
|
||||
timeElapsed(checkInTime, THRESH_HOLD)
|
||||
) {
|
||||
setStatus({
|
||||
status: "Request Regularize",
|
||||
action: ACTIONS.REGULARIZATION,
|
||||
disabled: false,
|
||||
text: "Regularize",
|
||||
color: 'btn-warning',
|
||||
color: "btn-warning",
|
||||
});
|
||||
} else if ( activity === 4 && checkInTime !== null && checkOutTime !== null && !timeElapsed( checkInTime, THRESH_HOLD ) )
|
||||
{
|
||||
|
||||
if ( activity === 4 && checkInTime !== null && checkOutTime !== null && new Date(checkOutTime).toDateString() !== new Date().toDateString())
|
||||
{
|
||||
setStatus( {
|
||||
} else if (
|
||||
activity === 4 &&
|
||||
checkInTime !== null &&
|
||||
checkOutTime !== null &&
|
||||
!timeElapsed(checkInTime, THRESH_HOLD)
|
||||
) {
|
||||
if (
|
||||
activity === 4 &&
|
||||
checkInTime !== null &&
|
||||
checkOutTime !== null &&
|
||||
new Date(checkOutTime).toDateString() !== new Date().toDateString()
|
||||
) {
|
||||
setStatus({
|
||||
status: "Approved",
|
||||
action: ACTIONS.APPROVED,
|
||||
disabled: true,
|
||||
text: "Approved",
|
||||
color: 'btn-success',
|
||||
} );
|
||||
} else
|
||||
{
|
||||
setStatus( {
|
||||
color: "btn-success",
|
||||
});
|
||||
} else {
|
||||
setStatus({
|
||||
status: "Check-In",
|
||||
action: ACTIONS.CHECK_IN,
|
||||
disabled: false,
|
||||
text: "Check In",
|
||||
color: 'btn-primary',
|
||||
} )
|
||||
color: "btn-primary",
|
||||
});
|
||||
}
|
||||
}
|
||||
else if ( activity === 2 && checkInTime !== null )
|
||||
{
|
||||
} else if (activity === 2 && checkInTime !== null) {
|
||||
setStatus({
|
||||
status: "Requested",
|
||||
action: ACTIONS.REQUESTED,
|
||||
disabled: true,
|
||||
text: "Requested",
|
||||
color: 'btn-info',
|
||||
color: "btn-info",
|
||||
});
|
||||
}else if(activity === 5 && checkInTime !== null ){
|
||||
|
||||
|
||||
} else if (activity === 5 && checkInTime !== null) {
|
||||
setStatus({
|
||||
status: "Rejected",
|
||||
action: ACTIONS.REJECTED,
|
||||
disabled: true,
|
||||
text: "Rejected",
|
||||
color: 'btn-danger',
|
||||
color: "btn-danger",
|
||||
});
|
||||
|
||||
}else {
|
||||
} else {
|
||||
setStatus({
|
||||
status: "Approved",
|
||||
action: ACTIONS.APPROVED,
|
||||
disabled: true,
|
||||
text: "Approved",
|
||||
color: 'btn-success',
|
||||
color: "btn-success",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}, [attendanceData]);
|
||||
|
||||
return status;
|
||||
|
@ -187,6 +187,13 @@ const DailyTask = () => {
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{!task_loading && TaskList.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={7} className="text-center">
|
||||
<p>No Reports Found</p>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{dates.map((date, i) => {
|
||||
return (
|
||||
<React.Fragment key={i}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user