From 9ea202cdb6ca3309f7a0bdb241409f35fdbfae59 Mon Sep 17 00:00:00 2001 From: Dominik Stumpf Date: Fri, 22 Nov 2024 13:53:27 +0100 Subject: [PATCH] refactor: move status text out of markup --- .../components/InfiniteScrollGuilds.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/explorer/components/InfiniteScrollGuilds.tsx b/src/app/explorer/components/InfiniteScrollGuilds.tsx index 172d5e73fe..34de0a187c 100644 --- a/src/app/explorer/components/InfiniteScrollGuilds.tsx +++ b/src/app/explorer/components/InfiniteScrollGuilds.tsx @@ -43,6 +43,15 @@ export const InfiniteScrollGuilds = () => { const guilds = data?.pages.flatMap((page) => page.items) || []; + let statusResponse: string | undefined; + if (isFetchingNextPage) { + statusResponse = "Loading more..."; + } else if (!hasNextPage && guilds.length) { + statusResponse = "No More Data"; + } else if (search && !isLoading) { + statusResponse = `No results for "${search}"`; + } + return (
@@ -61,18 +70,9 @@ export const InfiniteScrollGuilds = () => { )} aria-hidden /> - - {guilds.length === 0 && !isLoading && search ? ( -

- `No results for "${search}"` -

- ) : ( -

- {isFetchingNextPage - ? "Loading more..." - : hasNextPage || "No More Data"} -

- )} +

+ {statusResponse} +

); };