From 3bc9c9ae8ac70dca90362016108379aaaabd7cbd Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Mon, 21 Oct 2024 12:10:07 +0200 Subject: [PATCH] fix: handle loading states for project details for a single project --- .../personalDashboard/MyProjects.tsx | 24 +++++++++++++++---- .../personalDashboard/PersonalDashboard.tsx | 11 +++------ .../personalDashboard/ProjectDetailsError.tsx | 5 +--- .../personalDashboard/RoleAndOwnerInfo.tsx | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/frontend/src/component/personalDashboard/MyProjects.tsx b/frontend/src/component/personalDashboard/MyProjects.tsx index d509a93c37c3..06e9fd898c88 100644 --- a/frontend/src/component/personalDashboard/MyProjects.tsx +++ b/frontend/src/component/personalDashboard/MyProjects.tsx @@ -122,7 +122,10 @@ const ProjectListItem: FC<{ ); }; -type MyProjectsState = 'no projects' | 'projects' | 'projects with error'; +type MyProjectsState = + | 'no projects' + | 'projects' + | 'projects with error or loading'; export const MyProjects = forwardRef< HTMLDivElement, @@ -149,7 +152,7 @@ export const MyProjects = forwardRef< const state: MyProjectsState = projects.length ? personalDashboardProjectDetails ? 'projects' - : 'projects with error' + : 'projects with error or loading' : 'no projects'; const activeProjectStage = @@ -190,7 +193,7 @@ export const MyProjects = forwardRef< ), }; - case 'projects with error': + case 'projects with error or loading': return { list: ( @@ -206,8 +209,19 @@ export const MyProjects = forwardRef< ))} ), - box1: , - box2: , + box1: ( +
+ +
+ ), + box2: ( +
+ +
+ ), }; case 'projects': { diff --git a/frontend/src/component/personalDashboard/PersonalDashboard.tsx b/frontend/src/component/personalDashboard/PersonalDashboard.tsx index bba512e01923..a90bd95987e2 100644 --- a/frontend/src/component/personalDashboard/PersonalDashboard.tsx +++ b/frontend/src/component/personalDashboard/PersonalDashboard.tsx @@ -130,15 +130,10 @@ export const PersonalDashboard = () => { splash?.personalDashboardKeyConcepts ? 'closed' : 'open', ); - const { personalDashboardProjectDetails, error: detailsError } = + const { personalDashboardProjectDetails, loading: detailsLoading } = usePersonalDashboardProjectDetails(activeProject); - const activeProjectStage = - personalDashboardProjectDetails?.onboardingStatus.status ?? 'loading'; - - const projectStageRef = useLoading( - !detailsError && activeProjectStage === 'loading', - ); + const loadingProjectDetailsRef = useLoading(detailsLoading); return ( @@ -192,7 +187,7 @@ export const PersonalDashboard = () => { = ({ project }) => { return ( - +

The API request to get data for this project returned with an error. diff --git a/frontend/src/component/personalDashboard/RoleAndOwnerInfo.tsx b/frontend/src/component/personalDashboard/RoleAndOwnerInfo.tsx index fce80ebf17ed..f0b62053e608 100644 --- a/frontend/src/component/personalDashboard/RoleAndOwnerInfo.tsx +++ b/frontend/src/component/personalDashboard/RoleAndOwnerInfo.tsx @@ -51,7 +51,7 @@ export const RoleAndOwnerInfo = ({ roles, owners }: Props) => { const firstRoles = roles.slice(0, 3); const extraRoles = roles.slice(3); return ( - + {roles.length > 0 ? ( <>