fixed attendance logs and role name
This commit is contained in:
parent
453c53940f
commit
1483cab13f
@ -33,11 +33,12 @@ const AttendancePage = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
markTime: "",
|
time: "",
|
||||||
description: "",
|
description: "",
|
||||||
date: new Date().toLocaleDateString(),
|
date: new Date().toLocaleDateString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const getRole = (roleId) => {
|
const getRole = (roleId) => {
|
||||||
if (!empRoles) return "Unassigned";
|
if (!empRoles) return "Unassigned";
|
||||||
if (!roleId) return "Unassigned";
|
if (!roleId) return "Unassigned";
|
||||||
@ -66,26 +67,24 @@ const AttendancePage = () => {
|
|||||||
document.querySelector(".modal-backdrop").remove();
|
document.querySelector(".modal-backdrop").remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = ( formData ) =>
|
|
||||||
{
|
const handleSubmit = ( formData ) =>{
|
||||||
dispatch(markCurrentAttendance(formData))
|
dispatch( markCurrentAttendance( formData ) ).then( ( action ) =>
|
||||||
.then((action) => {
|
{
|
||||||
const updatedAttendance = attendances.map((item) =>
|
const updatedAttendance = attendances.map(item =>
|
||||||
item.employeeId === action.payload.employeeId
|
item.employeeId === action.payload.employeeId
|
||||||
? { ...item, ...action.payload }
|
? { ...item, ...action.payload }
|
||||||
: item
|
: item
|
||||||
);
|
);
|
||||||
cacheData("Attendance", {
|
cacheData("Attendance", { data: updatedAttendance, projectId: selectedProject })
|
||||||
data: updatedAttendance,
|
setAttendances(updatedAttendance)
|
||||||
projectId: selectedProject,
|
showToast("Attedance Marked Successfully","success")
|
||||||
});
|
})
|
||||||
setAttendances(updatedAttendance);
|
.catch( ( error ) =>
|
||||||
showToast("Attedance Marked Successfully", "success");
|
{
|
||||||
})
|
showToast(error.message,"error")
|
||||||
.catch((error) => {
|
});
|
||||||
showToast(error.message, "error");
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -126,70 +125,60 @@ const AttendancePage = () => {
|
|||||||
{ label: "Home", link: "/dashboard" },
|
{ label: "Home", link: "/dashboard" },
|
||||||
{ label: "Attendance", link: null },
|
{ label: "Attendance", link: null },
|
||||||
]}
|
]}
|
||||||
></Breadcrumb>
|
></Breadcrumb>
|
||||||
<div className="nav-align-top nav-tabs-shadow">
|
<div class="nav-align-top nav-tabs-shadow">
|
||||||
<ul className="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<div
|
<div
|
||||||
className="dataTables_length text-start py-2 px-2"
|
className="dataTables_length text-start py-2 px-2"
|
||||||
id="DataTables_Table_0_length"
|
id="DataTables_Table_0_length"
|
||||||
>
|
>
|
||||||
{loginUser && loginUser?.projects.length > 1 && (
|
{
|
||||||
<label>
|
((loginUser && loginUser?.projects.length > 1) ) && (<label>
|
||||||
<select
|
<select
|
||||||
name="DataTables_Table_0_length"
|
name="DataTables_Table_0_length"
|
||||||
aria-controls="DataTables_Table_0"
|
aria-controls="DataTables_Table_0"
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
value={selectedProject}
|
value={selectedProject}
|
||||||
onChange={(e) => dispatch(setProjectId(e.target.value))}
|
onChange={(e)=>dispatch(setProjectId(e.target.value))}
|
||||||
aria-label=""
|
aria-label=""
|
||||||
>
|
|
||||||
{!projectLoading &&
|
|
||||||
projects
|
|
||||||
?.filter((project) =>
|
|
||||||
loginUser?.projects?.map(Number).includes(project.id)
|
|
||||||
)
|
|
||||||
.map((project) => (
|
|
||||||
<option value={project.id}>{project.name}</option>
|
|
||||||
))}
|
|
||||||
{projectLoading && (
|
|
||||||
<option value="Loading..." disabled>
|
|
||||||
Loading...
|
|
||||||
</option>
|
|
||||||
)}
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</ul>
|
|
||||||
<ul className="nav nav-tabs" role="tablist">
|
|
||||||
<li className="nav-item">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="nav-link active"
|
|
||||||
role="tab"
|
|
||||||
data-bs-toggle="tab"
|
|
||||||
data-bs-target="#navs-top-home"
|
|
||||||
aria-controls="navs-top-home"
|
|
||||||
aria-selected="true"
|
|
||||||
>
|
>
|
||||||
All
|
{!projectLoading && projects?.filter(project =>
|
||||||
</button>
|
loginUser?.projects?.map(Number).includes(project.id)).map((project)=>(
|
||||||
</li>
|
<option value={project.id}>{project.name}</option>
|
||||||
<li className="nav-item">
|
))}
|
||||||
<button
|
{projectLoading && <option value="Loading..." disabled>Loading...</option> }
|
||||||
type="button"
|
</select>
|
||||||
className="nav-link"
|
</label>)
|
||||||
role="tab"
|
}
|
||||||
data-bs-toggle="tab"
|
</div>
|
||||||
data-bs-target="#navs-top-profile"
|
</ul>
|
||||||
aria-controls="navs-top-profile"
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
aria-selected="false"
|
<li class="nav-item">
|
||||||
>
|
<button
|
||||||
Logs
|
type="button"
|
||||||
</button>
|
class="nav-link active"
|
||||||
</li>
|
role="tab"
|
||||||
|
data-bs-toggle="tab"
|
||||||
<li className={`nav-item ${!DoRegularized && "d-none"}`}>
|
data-bs-target="#navs-top-home"
|
||||||
|
aria-controls="navs-top-home"
|
||||||
|
aria-selected="true">
|
||||||
|
All
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="nav-link"
|
||||||
|
role="tab"
|
||||||
|
data-bs-toggle="tab"
|
||||||
|
data-bs-target="#navs-top-profile"
|
||||||
|
aria-controls="navs-top-profile"
|
||||||
|
aria-selected="false">
|
||||||
|
Logs
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li className={`nav-item ${!DoRegularized && 'd-none'}`}>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="nav-link "
|
className="nav-link "
|
||||||
|
|||||||
@ -4,9 +4,7 @@ import {clearCacheKey} from '../apiDataManager';
|
|||||||
|
|
||||||
export const markCurrentAttendance = createAsyncThunk(
|
export const markCurrentAttendance = createAsyncThunk(
|
||||||
'attendanceCurrentDate/markAttendance',
|
'attendanceCurrentDate/markAttendance',
|
||||||
async ( formData, {getState, dispatch, rejectWithValue} ) =>
|
async (formData, { getState, dispatch, rejectWithValue }) => {
|
||||||
{
|
|
||||||
|
|
||||||
const { projectId } = getState().localVariables
|
const { projectId } = getState().localVariables
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user