From 173b1d0e51633045aa7f233ec14dab9778b28499 Mon Sep 17 00:00:00 2001 From: Toba Ojo Date: Wed, 3 Dec 2025 16:05:06 +0000 Subject: [PATCH] - improved statuses acress dashboard and child cards --- .../dashboard/components/DashboardGrid.tsx | 6 +++--- .../components/cameraStatus/CameraStatus.tsx | 21 +++++++++++++++---- .../statusGridItem/StatusGridItem.tsx | 3 ++- .../systemStatus/SystemStatusCard.tsx | 11 +++++++++- src/ui/ModalComponent.tsx | 2 +- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/features/dashboard/components/DashboardGrid.tsx b/src/features/dashboard/components/DashboardGrid.tsx index 1ac2c99..11fa94b 100644 --- a/src/features/dashboard/components/DashboardGrid.tsx +++ b/src/features/dashboard/components/DashboardGrid.tsx @@ -47,9 +47,9 @@ const DashboardGrid = () => { refetch={refetch} />
- - - + + +
); diff --git a/src/features/dashboard/components/cameraStatus/CameraStatus.tsx b/src/features/dashboard/components/cameraStatus/CameraStatus.tsx index 8165e44..bfbdfb5 100644 --- a/src/features/dashboard/components/cameraStatus/CameraStatus.tsx +++ b/src/features/dashboard/components/cameraStatus/CameraStatus.tsx @@ -7,10 +7,11 @@ import CameraStatusGridItem from "./CameraStatusGridItem"; type CameraStatusProps = { title: string; category: SystemHealthStatus[]; + isError?: boolean; }; -const CameraStatus = ({ title, category }: CameraStatusProps) => { - const isAllGood = category?.every((status) => status.tags.includes("RUNNING")); +const CameraStatus = ({ title, category, isError }: CameraStatusProps) => { + const isAllGood = category && category.length > 0 && category.every((status) => status.tags.includes("RUNNING")); // check if some are down // check if all are down //check if offline @@ -18,10 +19,22 @@ const CameraStatus = ({ title, category }: CameraStatusProps) => {

- {isAllGood ? : } + {isError ? ( + + ) : isAllGood ? ( + + ) : ( + + )} {capitalize(title)}

-

{isAllGood ? "All systems running" : "Some systems down"}

+ {isError ? ( +

Error loading camera health.

+ ) : isAllGood ? ( +

All systems running

+ ) : ( +

Some systems down

+ )}
{category && category?.length <= 0 ? (

Loading Camera health...

diff --git a/src/features/dashboard/components/statusGridItem/StatusGridItem.tsx b/src/features/dashboard/components/statusGridItem/StatusGridItem.tsx index faa7032..d3577f2 100644 --- a/src/features/dashboard/components/statusGridItem/StatusGridItem.tsx +++ b/src/features/dashboard/components/statusGridItem/StatusGridItem.tsx @@ -11,7 +11,8 @@ type StatusGridItemProps = { const StatusGridItem = ({ title, statusCategory }: StatusGridItemProps) => { const [isOpen, setIsOpen] = useState(false); - const isAllGood = statusCategory.every((status) => status.tags.includes("RUNNING")); + const isAllGood = + statusCategory && statusCategory.length > 0 && statusCategory.every((status) => status.tags.includes("RUNNING")); const handleClick = () => { setIsOpen(false); diff --git a/src/features/dashboard/components/systemStatus/SystemStatusCard.tsx b/src/features/dashboard/components/systemStatus/SystemStatusCard.tsx index 3017367..6260c0c 100644 --- a/src/features/dashboard/components/systemStatus/SystemStatusCard.tsx +++ b/src/features/dashboard/components/systemStatus/SystemStatusCard.tsx @@ -13,12 +13,21 @@ const SystemStatusCard = () => { const { storeQuery } = useGetStore(); const reads = storeQuery?.data; - const isReadsLoading = storeQuery.isFetching; + const isReadsLoading = storeQuery?.isFetching; + const isError = storeQuery?.isError || !storeQuery?.data; useEffect(() => { storeQuery.refetch(); }, [reads]); + if (isError) { + return ( + + + Error loading system status. + + ); + } return ( diff --git a/src/ui/ModalComponent.tsx b/src/ui/ModalComponent.tsx index 6a1684d..e433bd6 100644 --- a/src/ui/ModalComponent.tsx +++ b/src/ui/ModalComponent.tsx @@ -11,7 +11,7 @@ const ModalComponent = ({ isModalOpen, children, close }: ModalComponentProps) = {children} -- 2.25.1