pramod_Feature#51ProjectLisFilter #51

Merged
admin merged 4 commits from pramod_Feature#51ProjectLisFilter into Issues_April_4W 2025-04-25 11:00:45 +00:00
3 changed files with 24 additions and 21 deletions

View File

@ -49,19 +49,19 @@ export const useProjects = () =>
fetchData(); fetchData();
}, []); }, []);
useEffect( () => // useEffect( () =>
{ // {
if (projects ) // if (projects )
{ // {
if ( profile?.projects && profile?.projects?.length > 0 ) // if ( profile?.projects && profile?.projects?.length > 0 )
{ // {
dispatch(setProjectId(profile?.projects[0])) // dispatch(setProjectId(profile?.projects[0]))
} else // } else
{ // {
dispatch(setProjectId(1)) // dispatch(setProjectId(1))
} // }
} // }
}, [profile]); // }, [profile]);
return { projects, loading, error, refetch: fetchData }; return { projects, loading, error, refetch: fetchData };
}; };

View File

@ -34,20 +34,21 @@ 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) { if (!project_lodaing && projects.length > 0 && !initialized) {
const userProjects = projects.filter((p) => const userProjects = projects.filter((p) =>
LoggedUser?.projects?.map(Number).includes(p.id) LoggedUser?.projects?.map(Number).includes(p.id)
); );
if (projectId) { if (projectId) {
dispatch(setProjectId(projectId)); dispatch(setProjectId(projectId));
} else if (!selectedProject && userProjects.length > 0) { } else if (!selectedProject && userProjects.length > 0) {
dispatch(setProjectId(userProjects[0].id)); 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); const dispatch = useDispatch(selectedProject);
@ -58,13 +59,15 @@ const DailyTask = () => {
loading: task_loading, loading: task_loading,
error: task_error, error: task_error,
refetch, refetch,
} = useTaskList(selectedProject, dateRange.startDate, dateRange.endDate); } = useTaskList( initialized ? selectedProject : null,
initialized ? dateRange.startDate : null,
initialized ? dateRange.endDate : null);
const [TaskLists, setTaskLists] = useState([]); const [TaskLists, setTaskLists] = useState([]);
useEffect(() => { useEffect(() => {
setTaskLists(TaskList); setTaskLists(TaskList);
}, [TaskList, selectedProject]); }, [TaskList,selectedProject]);
const [selectedTask, selectTask] = useState(null); const [selectedTask, selectTask] = useState(null);
const [comments, setComment] = useState(null); const [comments, setComment] = useState(null);

View File

@ -293,7 +293,7 @@ const EmployeeList = () => {
</div> </div>
</div> </div>
<table <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" id="DataTables_Table_0"
aria-describedby="DataTables_Table_0_info" aria-describedby="DataTables_Table_0_info"
style={{ width: "100%" }} style={{ width: "100%" }}