Merge pull request 'pramod_Feature#51ProjectLisFilter' (#51) from pramod_Feature#51ProjectLisFilter into Issues_April_4W
Reviewed-on: #51
This commit is contained in:
commit
a2f6d77dcd
@ -49,19 +49,19 @@ export const useProjects = () =>
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
useEffect( () =>
|
||||
{
|
||||
if (projects )
|
||||
{
|
||||
if ( profile?.projects && profile?.projects?.length > 0 )
|
||||
{
|
||||
dispatch(setProjectId(profile?.projects[0]))
|
||||
} else
|
||||
{
|
||||
dispatch(setProjectId(1))
|
||||
}
|
||||
}
|
||||
}, [profile]);
|
||||
// useEffect( () =>
|
||||
// {
|
||||
// if (projects )
|
||||
// {
|
||||
// if ( profile?.projects && profile?.projects?.length > 0 )
|
||||
// {
|
||||
// dispatch(setProjectId(profile?.projects[0]))
|
||||
// } else
|
||||
// {
|
||||
// dispatch(setProjectId(1))
|
||||
// }
|
||||
// }
|
||||
// }, [profile]);
|
||||
|
||||
return { projects, loading, error, refetch: fetchData };
|
||||
};
|
||||
|
@ -34,7 +34,7 @@ const DailyTask = () => {
|
||||
|
||||
// Sync projectId (either from URL or pick first accessible one)
|
||||
useEffect(() => {
|
||||
if (!project_lodaing && projects.length > 0) {
|
||||
if (!project_lodaing && projects.length > 0 && !initialized) {
|
||||
const userProjects = projects.filter((p) =>
|
||||
LoggedUser?.projects?.map(Number).includes(p.id)
|
||||
);
|
||||
@ -45,9 +45,10 @@ const DailyTask = () => {
|
||||
dispatch(setProjectId(userProjects[0].id));
|
||||
}
|
||||
|
||||
setInitialized(true);
|
||||
setInitialized(true); // <-- This blocks re-running this effect again
|
||||
}
|
||||
}, [project_lodaing, projects, projectId, selectedProject]);
|
||||
}, [project_lodaing, projects, projectId, selectedProject, initialized]);
|
||||
|
||||
|
||||
|
||||
const dispatch = useDispatch(selectedProject);
|
||||
@ -58,7 +59,9 @@ const DailyTask = () => {
|
||||
loading: task_loading,
|
||||
error: task_error,
|
||||
refetch,
|
||||
} = useTaskList(selectedProject, dateRange.startDate, dateRange.endDate);
|
||||
} = useTaskList( initialized ? selectedProject : null,
|
||||
initialized ? dateRange.startDate : null,
|
||||
initialized ? dateRange.endDate : null);
|
||||
|
||||
const [TaskLists, setTaskLists] = useState([]);
|
||||
|
||||
|
@ -293,7 +293,7 @@ const EmployeeList = () => {
|
||||
</div>
|
||||
</div>
|
||||
<table
|
||||
className="datatables-users table border-top dataTable no-footer dtr-column "
|
||||
className="datatables-users table border-top dataTable no-footer dtr-column text-nowrap"
|
||||
id="DataTables_Table_0"
|
||||
aria-describedby="DataTables_Table_0_info"
|
||||
style={{ width: "100%" }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user