Skip to content

Commit

Permalink
refactor: move status text out of markup
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Nov 22, 2024
1 parent 107df80 commit 9ea202c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/app/explorer/components/InfiniteScrollGuilds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<section className="grid gap-2">
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
Expand All @@ -61,18 +70,9 @@ export const InfiniteScrollGuilds = () => {
)}
aria-hidden
/>

{guilds.length === 0 && !isLoading && search ? (
<p className="mt-6 text-center text-foreground-secondary">
`No results for "${search}"`
</p>
) : (
<p className="mt-6 text-center text-foreground-secondary">
{isFetchingNextPage
? "Loading more..."
: hasNextPage || "No More Data"}
</p>
)}
<p className="mt-6 text-center text-foreground-secondary">
{statusResponse}
</p>
</section>
);
};

0 comments on commit 9ea202c

Please sign in to comment.