import React,{useEffect} from "react";
import Breadcrumb from "../../components/common/Breadcrumb";
import InfraPlanning from "../../components/Activities/InfraPlanning";
import { useProjectName } from "../../hooks/useProjects";
import { useDispatch, useSelector } from "react-redux";
import { setProjectId } from "../../slices/localVariablesSlice";


const TaskPlannng = () => {
  const selectedProject = useSelector(
    (store) => store.localVariables.projectId
  );

  const dispatch = useDispatch()
    const { projectNames, loading: projectLoading, fetchData } = useProjectName();
  useEffect(() => {
   if(selectedProject == null){
       dispatch(setProjectId(projectNames[0]?.id));
   }
   },[])

  return (
    <>
      <div className="container-fluid">
        <Breadcrumb
          data={[
            { label: "Home", link: "/dashboard" },
            { label: "Daily Task Planning" }
          ]}
        ></Breadcrumb>
          <InfraPlanning/>
      </div>
    </>
  );
};

export default TaskPlannng;
