Removed unnecessary logged-in user project filtering from the UI.
This commit is contained in:
parent
02f37be504
commit
a7129c4187
@ -47,8 +47,7 @@ const InfraPlanning = () =>
|
|||||||
>
|
>
|
||||||
{(project_listLoader || projects.length < 0) && <option value="Loading..." disabled>Loading...</option> }
|
{(project_listLoader || projects.length < 0) && <option value="Loading..." disabled>Loading...</option> }
|
||||||
|
|
||||||
{!project_listLoader && projects?.filter(project =>
|
{!project_listLoader && projects?.map((project)=>(
|
||||||
LoggedUser?.projects?.map(Number).includes(project.id)).map((project)=>(
|
|
||||||
<option key={project.id} value={project.id}>{project.name}</option>
|
<option key={project.id} value={project.id}>{project.name}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { dailyTask } from "../../data/masters";
|
|||||||
import { useTaskList } from "../../hooks/useTasks";
|
import { useTaskList } from "../../hooks/useTasks";
|
||||||
import { useProjects } from "../../hooks/useProjects";
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
|
||||||
import { formatDate } from "../../utils/dateUtils";
|
import { formatDate } from "../../utils/dateUtils";
|
||||||
import GlobalModel from "../../components/common/GlobalModel";
|
import GlobalModel from "../../components/common/GlobalModel";
|
||||||
import AssignRoleModel from "../../components/Project/AssignRole";
|
import AssignRoleModel from "../../components/Project/AssignRole";
|
||||||
@ -16,7 +15,6 @@ import DatePicker from "../../components/common/DatePicker";
|
|||||||
import { useSearchParams } from "react-router-dom";
|
import { useSearchParams } from "react-router-dom";
|
||||||
|
|
||||||
const DailyTask = () => {
|
const DailyTask = () => {
|
||||||
const { profile: LoggedUser } = useProfile();
|
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const projectId = searchParams.get("project");
|
const projectId = searchParams.get("project");
|
||||||
const selectedProject = useSelector(
|
const selectedProject = useSelector(
|
||||||
@ -32,20 +30,15 @@ const DailyTask = () => {
|
|||||||
|
|
||||||
const [initialized, setInitialized] = useState(false);
|
const [initialized, setInitialized] = useState(false);
|
||||||
|
|
||||||
// Sync projectId (either from URL or pick first accessible one)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!project_lodaing && projects.length > 0 && !initialized) {
|
if (!project_lodaing && projects.length > 0 && !initialized) {
|
||||||
const userProjects = projects.filter((p) =>
|
|
||||||
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) {
|
||||||
dispatch(setProjectId(userProjects[0].id));
|
dispatch(setProjectId(projects[0].id));
|
||||||
}
|
}
|
||||||
|
|
||||||
setInitialized(true); // <-- This blocks re-running this effect again
|
setInitialized(true);
|
||||||
}
|
}
|
||||||
}, [project_lodaing, projects, projectId, selectedProject, initialized]);
|
}, [project_lodaing, projects, projectId, selectedProject, initialized]);
|
||||||
|
|
||||||
@ -136,16 +129,13 @@ const DailyTask = () => {
|
|||||||
onChange={(e) => dispatch(setProjectId(e.target.value))}
|
onChange={(e) => dispatch(setProjectId(e.target.value))}
|
||||||
aria-label=""
|
aria-label=""
|
||||||
>
|
>
|
||||||
{(project_lodaing || projects.length < 0) && (
|
{(project_lodaing ) && (
|
||||||
<option value="Loading..." disabled>
|
<option value="Loading..." disabled>
|
||||||
Loading...
|
Loading...
|
||||||
</option>
|
</option>
|
||||||
)}
|
)}
|
||||||
{!project_lodaing &&
|
{(!project_lodaing && projects) &&
|
||||||
projects
|
projects
|
||||||
?.filter((project) =>
|
|
||||||
LoggedUser?.projects?.map(Number).includes(project.id)
|
|
||||||
)
|
|
||||||
.map((project) => (
|
.map((project) => (
|
||||||
<option value={project.id} key={project.id}>
|
<option value={project.id} key={project.id}>
|
||||||
{project.name}
|
{project.name}
|
||||||
@ -171,7 +161,7 @@ const DailyTask = () => {
|
|||||||
{TaskLists?.length === 0 && !task_loading && (
|
{TaskLists?.length === 0 && !task_loading && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={7} className="text-center">
|
<td colSpan={7} className="text-center">
|
||||||
No Data Found
|
No Task Found
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
@ -179,15 +169,11 @@ const DailyTask = () => {
|
|||||||
{task_loading && (
|
{task_loading && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={7} className="text-center">
|
<td colSpan={7} className="text-center">
|
||||||
<p>Loading..</p>
|
<p>Loading.;;.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
{(!initialized || !selectedProject) && ( <tr>
|
|
||||||
<td colSpan={7} className="text-center">
|
|
||||||
<p>Loading..</p>
|
|
||||||
</td>
|
|
||||||
</tr>)}
|
|
||||||
|
|
||||||
{TaskLists.map((task, index) => {
|
{TaskLists.map((task, index) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user