From 4e2cad790b6f545609f6120396ada026ad0d62c7 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Mon, 9 Mar 2026 23:11:15 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=B6Added=20visibility=20guards=20to=20?= =?UTF-8?q?volumes,=20stats=20and=20wanted=20on=20dashboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/components/Dashboard/LibraryStatistics.tsx | 2 +- src/client/components/Dashboard/VolumeGroups.tsx | 4 +++- src/client/components/Dashboard/WantedComicsList.tsx | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/components/Dashboard/LibraryStatistics.tsx b/src/client/components/Dashboard/LibraryStatistics.tsx index 68a8b21..59faaae 100644 --- a/src/client/components/Dashboard/LibraryStatistics.tsx +++ b/src/client/components/Dashboard/LibraryStatistics.tsx @@ -19,7 +19,7 @@ interface LibraryStatisticsProps { * Returns `null` when `stats` is absent or the statistics array is empty. */ export const LibraryStatistics = ({ stats }: LibraryStatisticsProps): ReactElement | null => { - if (!stats) return null; + if (!stats || !stats.totalDocuments) return null; const facet = stats.statistics?.[0]; if (!facet) return null; diff --git a/src/client/components/Dashboard/VolumeGroups.tsx b/src/client/components/Dashboard/VolumeGroups.tsx index 1b6b1a8..47ea34c 100644 --- a/src/client/components/Dashboard/VolumeGroups.tsx +++ b/src/client/components/Dashboard/VolumeGroups.tsx @@ -11,9 +11,11 @@ type VolumeGroupsProps = { volumeGroups?: GetVolumeGroupsQuery['getComicBookGroups']; }; -export const VolumeGroups = (props: VolumeGroupsProps): ReactElement => { +export const VolumeGroups = (props: VolumeGroupsProps): ReactElement | null => { // Till mongo gives us back the deduplicated results with the ObjectId const deduplicatedGroups = unionBy(props.volumeGroups, "volumes.id"); + if (!deduplicatedGroups || deduplicatedGroups.length === 0) return null; + const navigate = useNavigate(); const navigateToVolumes = (row: any) => { navigate(`/volumes/all`); diff --git a/src/client/components/Dashboard/WantedComicsList.tsx b/src/client/components/Dashboard/WantedComicsList.tsx index e0c4aca..9dff62f 100644 --- a/src/client/components/Dashboard/WantedComicsList.tsx +++ b/src/client/components/Dashboard/WantedComicsList.tsx @@ -15,7 +15,9 @@ type WantedComicsListProps = { export const WantedComicsList = ({ comics, -}: WantedComicsListProps): ReactElement => { +}: WantedComicsListProps): ReactElement | null => { + if (!comics || comics.length === 0) return null; + const navigate = useNavigate(); // embla carousel