feat: add user count endpoint and integrate it into frontend components
All checks were successful
Build and Deploy Thoughts / build-and-deploy-local (push) Successful in 19s
All checks were successful
Build and Deploy Thoughts / build-and-deploy-local (push) Successful in 19s
This commit is contained in:
@@ -14,6 +14,7 @@ import { PopularTags } from "@/components/popular-tags";
|
||||
import { ThoughtThread } from "@/components/thought-thread";
|
||||
import { buildThoughtThreads } from "@/lib/utils";
|
||||
import { TopFriends } from "@/components/top-friends";
|
||||
import { UsersCount } from "@/components/users-count";
|
||||
|
||||
export default async function Home() {
|
||||
const token = (await cookies()).get("auth_token")?.value ?? null;
|
||||
@@ -92,6 +93,7 @@ async function FeedPage({ token }: { token: string }) {
|
||||
)}
|
||||
<PopularTags />
|
||||
{token && <TopFriends mode="friends" usernames={friends || []} />}
|
||||
<UsersCount />
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
63
thoughts-frontend/app/users/all/page.tsx
Normal file
63
thoughts-frontend/app/users/all/page.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import { getAllUsers } from "@/lib/api";
|
||||
import { UserListCard } from "@/components/user-list-card";
|
||||
import {
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
PaginationItem,
|
||||
PaginationNext,
|
||||
PaginationPrevious,
|
||||
} from "@/components/ui/pagination";
|
||||
|
||||
export default async function AllUsersPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: { page?: string };
|
||||
}) {
|
||||
const page = parseInt(searchParams.page ?? "1", 10);
|
||||
const usersData = await getAllUsers(page).catch(() => null);
|
||||
|
||||
if (!usersData) {
|
||||
return (
|
||||
<div className="container mx-auto max-w-2xl p-4 sm:p-6 text-center">
|
||||
<h1 className="text-3xl font-bold my-6">All Users</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Could not load users. Please try again later.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { items, totalPages } = usersData;
|
||||
|
||||
return (
|
||||
<div className="container mx-auto max-w-2xl p-4 sm:p-6">
|
||||
<header className="my-6 glass-effect glossy-effect bottom gloss-highlight rounded-md p-4 text-shadow-md">
|
||||
<h1 className="text-3xl font-bold">All Users</h1>
|
||||
<p className="text-muted-foreground">
|
||||
Discover other users on Thoughts.
|
||||
</p>
|
||||
</header>
|
||||
<main>
|
||||
<UserListCard users={items} />
|
||||
{totalPages > 1 && (
|
||||
<Pagination className="mt-8">
|
||||
<PaginationContent>
|
||||
<PaginationItem>
|
||||
<PaginationPrevious
|
||||
href={page > 1 ? `/users/all?page=${page - 1}` : "#"}
|
||||
aria-disabled={page <= 1}
|
||||
/>
|
||||
</PaginationItem>
|
||||
<PaginationItem>
|
||||
<PaginationNext
|
||||
href={page < totalPages ? `/users/all?page=${page + 1}` : "#"}
|
||||
aria-disabled={page >= totalPages}
|
||||
/>
|
||||
</PaginationItem>
|
||||
</PaginationContent>
|
||||
</Pagination>
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user