Skip to content

Commit

Permalink
improvement: display user counts
Browse files Browse the repository at this point in the history
  • Loading branch information
acatzk committed Feb 2, 2024
1 parent 9b4f195 commit 9559e98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/layouts/profile-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ export default function ProfileLayout({ children }: ProfileLayoutProps): JSX.Ele
</div>
<div className="flex items-center space-x-4">
<a href="#" className="inline-flex items-center space-x-1 hover:underline">
<h4 className="font-bold">0</h4>
<h4 className="font-bold">{user?.data?._count.posts}</h4>
<span>posts</span>
</a>
<a href="#" className="inline-flex items-center space-x-1 hover:underline">
<h4 className="font-bold">0</h4>
<h4 className="font-bold">{user?.data?._count.followers}</h4>
<span>followers</span>
</a>
<a href="#" className="inline-flex items-center space-x-1 hover:underline">
<h4 className="font-bold">0</h4>
<h4 className="font-bold">{user?.data?._count.following}</h4>
<span>following</span>
</a>
</div>
Expand Down
13 changes: 13 additions & 0 deletions server/api/routers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ export const userRouter = createTRPCRouter({
return await ctx.db.user.findUniqueOrThrow({
where: {
username: input.username
},
select: {
id: true,
displayName: true,
imageUrl: true,
username: true,
_count: {
select: {
posts: true,
followers: true,
following: true
}
}
}
})
}),
Expand Down

0 comments on commit 9559e98

Please sign in to comment.