Skip to content

Commit

Permalink
Merge pull request #234 from wizelineacademy/dev
Browse files Browse the repository at this point in the history
hotfix pcp page when there's no project data
  • Loading branch information
pedroalonsoms authored Jun 14, 2024
2 parents f80e5e1 + 101aaf6 commit f5e0320
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions app/(base)/pcp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const statusOptions = [
];

const PCP = () => {
const [projectId, setProjectId] = useState<number>();
const [projectId, setProjectId] = useState<number>(-1);
const queryClient = useQueryClient();
const [progressPercentage, setProgressPercentage] = useState<number>(0);

Expand All @@ -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]);

Expand Down Expand Up @@ -91,13 +96,12 @@ const PCP = () => {
});
};

if (
projectsQuery.isError ||
(projectsQuery.data && projectsQuery.data.length === 0)
) {
return (
<NoDataCard text="You dont have projects or there was an error fetching the data" />
);
if (projectsQuery.isError) {
return <NoDataCard text="There was an error fetching the data" />;
}

if (projectsQuery.data && projectsQuery.data.length === 0) {
return <NoDataCard text="You dont have projects" />;
}

if (projectsQuery.isLoading) {
Expand Down

0 comments on commit f5e0320

Please sign in to comment.