From 052ae9b4c5ec88a001f7377eab0e4e49fcb943fc Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sat, 28 Dec 2024 12:39:31 +0000 Subject: fix: Better handling for when there's no highlights in the all highlights page --- apps/web/components/dashboard/highlights/AllHighlights.tsx | 14 +++++++++++--- apps/web/lib/i18n/locales/en/translation.json | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/web/components/dashboard/highlights/AllHighlights.tsx b/apps/web/components/dashboard/highlights/AllHighlights.tsx index 27dda6ff..98e17e2b 100644 --- a/apps/web/components/dashboard/highlights/AllHighlights.tsx +++ b/apps/web/components/dashboard/highlights/AllHighlights.tsx @@ -47,6 +47,7 @@ export default function AllHighlights({ }: { highlights: ZGetAllHighlightsResponse; }) { + const { t } = useTranslation(); const { data, fetchNextPage, hasNextPage, isFetchingNextPage } = api.highlights.getAll.useInfiniteQuery( {}, @@ -67,11 +68,13 @@ export default function AllHighlights({ } }, [loadMoreButtonInView]); + const allHighlights = data?.pages.flatMap((p) => p.highlights); + return (
- {data?.pages - .flatMap((p) => p.highlights) - .map((h) => ( + {allHighlights && + allHighlights.length > 0 && + allHighlights.map((h) => ( <> ))} + {allHighlights && allHighlights.length == 0 && ( +

+ {t("highlights.no_highlights")} +

+ )} {hasNextPage && (