Compare commits

..

No commits in common. "5559970a05bf81c3d740820980b16dcd7ffc2401" and "147342bfc185556613e89d13345ca1e4c513b6f6" have entirely different histories.

3 changed files with 10 additions and 26 deletions

View File

@ -29,7 +29,7 @@ const InfraPlanning = () =>
useEffect( () =>
{
dispatch(setProjectId(projects[0]?.id))
},[projects])
})
return (
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
@ -49,7 +49,7 @@ const InfraPlanning = () =>
{!project_listLoader && projects?.filter(project =>
LoggedUser?.projects?.map(Number).includes(project.id)).map((project)=>(
<option key={project.id} value={project.id}>{project.name}</option>
<option value={project.id}>{project.name}</option>
))}
</select>
</div>

View File

@ -4,7 +4,6 @@ import {
getCachedData,
} from "../slices/apiDataManager"
import ProjectRepository from "../repositories/ProjectRepository";
import { useProfile } from "./useProfile";
@ -85,7 +84,7 @@ export const useEmployeesByProjectAllocated = ( selectedProject ) =>
}
export const useProjectDetails =(projectId)=>{
const {profile} = useProfile();
const [projects_Details, setProject_Details] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState("");
@ -114,11 +113,11 @@ export const useProjectDetails =(projectId)=>{
};
useEffect(()=>{
if ( profile && (projectId != undefined) )
if ( projectId )
{
fetchData()
}
},[projectId,profile])
},[projectId])
return { projects_Details,loading,error,refetch:fetchData}

View File

@ -6,19 +6,10 @@ import ProjectRepository from "../../repositories/ProjectRepository";
import Breadcrumb from "../../components/common/Breadcrumb";
import InfraPlanning from "../../components/Activities/InfraPlanning";
import { cacheData, getCachedData } from "../../slices/apiDataManager";
import { useProfile } from "../../hooks/useProfile";
import { useDispatch, useSelector } from "react-redux";
import { useProjectDetails, useProjects } from "../../hooks/useProjects";
import { setProjectId } from "../../slices/localVariablesSlice";
var projectId;
const TaskPlannng = () => {
const {profile} = useProfile();
const {projects,loading:project_listLoader,error:projects_error} = useProjects();
const dispatch = useDispatch();
const selectedProject = useSelector((store)=>store.localVariables.projectId);
const [project, setProject] = useState(null);
const [projectDetails, setProjectDetails] = useState(null);
@ -26,10 +17,6 @@ const TaskPlannng = () => {
const [loading, setLoading] = useState(true);
const [error, setError] = useState("");
useEffect( () =>
{
dispatch(setProjectId(projects[0]?.id))
},[projects])
const fetchActivities = async () => {
try {
@ -56,9 +43,9 @@ const TaskPlannng = () => {
const fetchData = async () => {
try {
const project_cache = getCachedData(`projectinfo-${selectedProject}`);
const project_cache = getCachedData(`projectinfo-${1}`);
if (!project_cache) {
ProjectRepository.getProjectByprojectId(selectedProject)
ProjectRepository.getProjectByprojectId(1)
.then((response) => {
setProjectDetails(response);
setProject(response);
@ -86,16 +73,14 @@ const TaskPlannng = () => {
};
const handleDataChange = (data) => {
console.log("datachange")
fetchData();
};
useEffect(() => {
if((projects.length != 0)){
fetchData();
projectId =1
fetchData();
fetchActivities();
}
}, [selectedProject]);
}, []);
return (