diff --git a/src/hooks/useProjects.js b/src/hooks/useProjects.js index b3ed250b..91590580 100644 --- a/src/hooks/useProjects.js +++ b/src/hooks/useProjects.js @@ -7,17 +7,10 @@ import { setProjectId } from "../slices/localVariablesSlice"; export const useProjects = () => { const { profile } = useProfile(); - const dispatch = useDispatch(); const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(""); - const fetchData = async () => - { - console.log("calldd") - const projectIds = profile?.projects || []; - - const projects_cache = getCachedData("projectslist"); const fetchData = async () => { const projectIds = profile?.projects || []; @@ -26,7 +19,8 @@ export const useProjects = () => { .filter((proj) => projectIds.includes(String(proj.id))) .sort((a, b) => a.name.localeCompare(b.name)); }; - const projects_cache = getCachedData("projectList") + + const projects_cache = getCachedData("projectslist"); if (!projects_cache) { setLoading(true); @@ -44,26 +38,18 @@ export const useProjects = () => { } else { if (!projects.length) { const filtered = filterProjects(projects_cache); - setProjects( filtered ); + setProjects(filtered); setLoading(false); } } }; - useEffect( () => - { - - if ( profile ) - { useEffect(() => { if (profile) { fetchData(); } }, [profile]); - - }, [profile]); - return { projects, loading, error, refetch: fetchData }; }; @@ -142,5 +128,5 @@ export const useProjectDetails = (projectId) => { } }, [projectId, profile]); - return { projects_Details, loading, error, refetch: fetchData }; -}; + return { projects_Details, loading, error, refetch: fetchData } +}