From 101aaf67dc17f6fbfa9ecde1bd56f168711961d9 Mon Sep 17 00:00:00 2001 From: pedroalonsoms Date: Thu, 13 Jun 2024 22:57:56 -0600 Subject: [PATCH] hotfix pcp page when there's no project data --- app/(base)/pcp/page.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/(base)/pcp/page.tsx b/app/(base)/pcp/page.tsx index 7f27b58..40365e2 100644 --- a/app/(base)/pcp/page.tsx +++ b/app/(base)/pcp/page.tsx @@ -34,7 +34,7 @@ const statusOptions = [ ]; const PCP = () => { - const [projectId, setProjectId] = useState(); + const [projectId, setProjectId] = useState(-1); const queryClient = useQueryClient(); const [progressPercentage, setProgressPercentage] = useState(0); @@ -46,7 +46,12 @@ const PCP = () => { }); useEffect(() => { - if (!projectsQuery.data) return; + if ( + !projectsQuery.data || + (projectsQuery.data && projectsQuery.data.length === 0) + ) { + return; + } setProjectId(projectsQuery.data[0].id); }, [projectsQuery.data]); @@ -91,13 +96,12 @@ const PCP = () => { }); }; - if ( - projectsQuery.isError || - (projectsQuery.data && projectsQuery.data.length === 0) - ) { - return ( - - ); + if (projectsQuery.isError) { + return ; + } + + if (projectsQuery.data && projectsQuery.data.length === 0) { + return ; } if (projectsQuery.isLoading) {