diff --git a/src/hooks/useProjects.js b/src/hooks/useProjects.js index e7e9aa14..b3ed250b 100644 --- a/src/hooks/useProjects.js +++ b/src/hooks/useProjects.js @@ -12,6 +12,11 @@ export const useProjects = () => { 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 || []; @@ -21,6 +26,7 @@ export const useProjects = () => { .filter((proj) => projectIds.includes(String(proj.id))) .sort((a, b) => a.name.localeCompare(b.name)); }; + const projects_cache = getCachedData("projectList") if (!projects_cache) { setLoading(true); @@ -44,12 +50,20 @@ export const useProjects = () => { } }; + useEffect( () => + { + + if ( profile ) + { useEffect(() => { if (profile) { fetchData(); } }, [profile]); + + }, [profile]); + return { projects, loading, error, refetch: fetchData }; };