Fixed the error "project not found" in daily task planning
This commit is contained in:
parent
147342bfc1
commit
f9c6d1b7f8
@ -29,7 +29,7 @@ const InfraPlanning = () =>
|
|||||||
useEffect( () =>
|
useEffect( () =>
|
||||||
{
|
{
|
||||||
dispatch(setProjectId(projects[0]?.id))
|
dispatch(setProjectId(projects[0]?.id))
|
||||||
})
|
},[projects])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
||||||
|
@ -4,6 +4,7 @@ import {
|
|||||||
getCachedData,
|
getCachedData,
|
||||||
} from "../slices/apiDataManager"
|
} from "../slices/apiDataManager"
|
||||||
import ProjectRepository from "../repositories/ProjectRepository";
|
import ProjectRepository from "../repositories/ProjectRepository";
|
||||||
|
import { useProfile } from "./useProfile";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ export const useEmployeesByProjectAllocated = ( selectedProject ) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useProjectDetails =(projectId)=>{
|
export const useProjectDetails =(projectId)=>{
|
||||||
|
const {profile} = useProfile();
|
||||||
const [projects_Details, setProject_Details] = useState(null);
|
const [projects_Details, setProject_Details] = useState(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
@ -113,11 +114,11 @@ export const useProjectDetails =(projectId)=>{
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if ( projectId )
|
if ( profile && (projectId != undefined) )
|
||||||
{
|
{
|
||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
},[projectId])
|
},[projectId,profile])
|
||||||
|
|
||||||
return { projects_Details,loading,error,refetch:fetchData}
|
return { projects_Details,loading,error,refetch:fetchData}
|
||||||
|
|
||||||
|
@ -6,10 +6,19 @@ import ProjectRepository from "../../repositories/ProjectRepository";
|
|||||||
import Breadcrumb from "../../components/common/Breadcrumb";
|
import Breadcrumb from "../../components/common/Breadcrumb";
|
||||||
import InfraPlanning from "../../components/Activities/InfraPlanning";
|
import InfraPlanning from "../../components/Activities/InfraPlanning";
|
||||||
import { cacheData, getCachedData } from "../../slices/apiDataManager";
|
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;
|
var projectId;
|
||||||
const TaskPlannng = () => {
|
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 [project, setProject] = useState(null);
|
||||||
const [projectDetails, setProjectDetails] = useState(null);
|
const [projectDetails, setProjectDetails] = useState(null);
|
||||||
@ -17,6 +26,10 @@ const TaskPlannng = () => {
|
|||||||
|
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
useEffect( () =>
|
||||||
|
{
|
||||||
|
dispatch(setProjectId(projects[0]?.id))
|
||||||
|
},[projects])
|
||||||
|
|
||||||
const fetchActivities = async () => {
|
const fetchActivities = async () => {
|
||||||
try {
|
try {
|
||||||
@ -43,9 +56,9 @@ const TaskPlannng = () => {
|
|||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const project_cache = getCachedData(`projectinfo-${1}`);
|
const project_cache = getCachedData(`projectinfo-${selectedProject}`);
|
||||||
if (!project_cache) {
|
if (!project_cache) {
|
||||||
ProjectRepository.getProjectByprojectId(1)
|
ProjectRepository.getProjectByprojectId(selectedProject)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
setProjectDetails(response);
|
setProjectDetails(response);
|
||||||
setProject(response);
|
setProject(response);
|
||||||
@ -73,14 +86,16 @@ const TaskPlannng = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDataChange = (data) => {
|
const handleDataChange = (data) => {
|
||||||
|
console.log("datachange")
|
||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
projectId =1
|
if((projects.length != 0)){
|
||||||
fetchData();
|
fetchData();
|
||||||
fetchActivities();
|
fetchActivities();
|
||||||
}, []);
|
}
|
||||||
|
}, [selectedProject]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user