From a0738bdd115f6205d1e268b3d9b92dc63fcb8b1d Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Fri, 6 Dec 2024 13:48:41 +0100 Subject: [PATCH] ui: show health status fetch error --- .../HealthStatus/HealthModal/HealthModal.tsx | 110 +++++++++++------- frontend/app/components/Signup/Signup.tsx | 11 +- 2 files changed, 76 insertions(+), 45 deletions(-) diff --git a/frontend/app/components/Header/HealthStatus/HealthModal/HealthModal.tsx b/frontend/app/components/Header/HealthStatus/HealthModal/HealthModal.tsx index f8dc428a6..06f0b1cee 100644 --- a/frontend/app/components/Header/HealthStatus/HealthModal/HealthModal.tsx +++ b/frontend/app/components/Header/HealthStatus/HealthModal/HealthModal.tsx @@ -17,7 +17,10 @@ function HealthModal({ }: { getHealth: () => void; isLoading: boolean; - healthResponse: { overallHealth: boolean; healthMap: Record }; + healthResponse: { + overallHealth: boolean; + healthMap: Record; + }; setShowModal: (isOpen: boolean) => void; setPassed?: () => void; }) { @@ -39,7 +42,7 @@ function HealthModal({ setShowModal(false); }; - const isSetup = document.location.pathname.includes('/signup') + const isSetup = document.location.pathname.includes('/signup'); return (
e.stopPropagation()} - className={'flex flex-col bg-white rounded border border-figmaColors-divider'} + className={ + 'flex flex-col bg-white rounded border border-figmaColors-divider' + } >
-
-
- {isLoading ? null - : Object.keys(healthResponse.healthMap).map((service) => ( - - setSelectedService(service)} - healthOk={healthResponse.healthMap[service].healthOk} - name={healthResponse.healthMap[service].name} - isSelectable - isSelected={selectedService === service} + {healthResponse ? ( + <> +
+
+ {isLoading + ? null + : Object.keys(healthResponse.healthMap).map((service) => ( + + setSelectedService(service)} + healthOk={ + healthResponse.healthMap[service].healthOk + } + name={healthResponse.healthMap[service].name} + isSelectable + isSelected={selectedService === service} + /> + + ))} +
+
+ {isLoading ? null : selectedService ? ( + - - ))} + ) : ( + + )} +
+
+ {isSetup ? ( +
+ +
+ ) : null} + + ) : ( +
+
Error while fetching data...
-
- {isLoading ? null : selectedService ? ( - - ) : - } -
-
- {isSetup ? ( -
- -
- ) : null} + )}
@@ -137,7 +160,10 @@ function ServiceStatus({ service }: { service: Record }) {
{Object.keys(subservices).map((subservice: string) => ( - + ))}
diff --git a/frontend/app/components/Signup/Signup.tsx b/frontend/app/components/Signup/Signup.tsx index b5538cc10..f8704c54b 100644 --- a/frontend/app/components/Signup/Signup.tsx +++ b/frontend/app/components/Signup/Signup.tsx @@ -33,9 +33,14 @@ const Signup: React.FC = ({ history }) => { const getHealth = async () => { setHealthStatusLoading(true); - const { healthMap } = await getHealthRequest(true); - setHealthStatus(healthMap); - setHealthStatusLoading(false); + try { + const { healthMap } = await getHealthRequest(true); + setHealthStatus(healthMap); + } catch (e) { + console.error(e); + } finally { + setHealthStatusLoading(false); + } }; useEffect(() => {