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();
}, []);
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 };
};

View File

@ -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,13 +59,15 @@ 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([]);
useEffect(() => {
setTaskLists(TaskList);
}, [TaskList, selectedProject]);
}, [TaskList,selectedProject]);
const [selectedTask, selectTask] = useState(null);
const [comments, setComment] = useState(null);

View File

@ -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%" }}