diff --git a/app/(content)/(user)/[username]/followers/page.tsx b/app/(content)/(user)/[username]/followers/page.tsx index 5ea8f4daa5c5fef29b079a07c60284b12ab27cba..861d82fdbfef3ccae10349c046538f3609a7f863 100644 --- a/app/(content)/(user)/[username]/followers/page.tsx +++ b/app/(content)/(user)/[username]/followers/page.tsx @@ -1,7 +1,26 @@ -export default async function Following() { +import { BackHeader } from "@/components/back-header" +import { GlobalLayout } from "@/components/global-layout" +import { UserFollows } from "@/components/profile/components/user-follows" +import { Card } from "@/components/ui/card" +import { getCurrentUser } from "@/lib/session" + +export default async function Followers({ params }: { params: { username: string } }) { + const session = await getCurrentUser() + return ( - <div> - <h1>Following Page WIP</h1> - </div> + <GlobalLayout + mainContent={ + <Card className="w-full overflow-hidden "> + <div className="p-3"> + <BackHeader> + <h1 className="font-bold">Followers</h1> + </BackHeader> + </div> + <div className="px-5"> + <UserFollows username={params.username} session={session} /> + </div> + </Card> + } + /> ) } \ No newline at end of file diff --git a/components/profile/components/user-follows.tsx b/components/profile/components/user-follows.tsx index afd3d0fade42a736af50e264a4bef370a7eae3c7..69daa9abe1f780dfc4199a878671abe3c2298ed3 100644 --- a/components/profile/components/user-follows.tsx +++ b/components/profile/components/user-follows.tsx @@ -36,8 +36,17 @@ export const UserFollows = ({ username, session }: { username: string, session: return ( <div className="m-6 flex justify-center"> <div className="font-bold"> - <h1>You are not following anyone.</h1> - <p>When you do, it'll show up here.</p> + {pathValue === "following" ? + <> + <h1>You are not following anyone.</h1> + <p>When you do, it'll show up here.</p> + </> + : + <> + <h1>You have no followers.</h1> + <p>When you do, they'll show up here.</p> + </> + } </div> </div> ) @@ -45,8 +54,17 @@ export const UserFollows = ({ username, session }: { username: string, session: return ( <div className="m-6 flex justify-center"> <div className="font-bold"> - <h1><span className="text-sky-500">@{username}</span> is not following anyone yet.</h1> - <p>When they do, it'll show up here.</p> + {pathValue === "following" ? + <> + <h1><span className="text-sky-500">@{username}</span> is not following anyone yet.</h1> + <p>When they do, it'll show up here.</p> + </> + : + <> + <h1><span className="text-sky-500">@{username}</span> has no followers.</h1> + <p>When they do, they'll show up here.</p> + </> + } </div> </div> ) diff --git a/components/profile/components/user-item.tsx b/components/profile/components/user-item.tsx index 8a8f81dba302e0a066c355f98ae5069516221803..20fa31d8ae804283844d11b0c2a3fff8f4d208af 100644 --- a/components/profile/components/user-item.tsx +++ b/components/profile/components/user-item.tsx @@ -4,7 +4,7 @@ import Link from "next/link" import { IUser } from "../types" import { following } from "../utils/following" -export const UserItem = ({ user, sessionId }: { user: IUser, sessionId: string | undefined }) => { +export const UserItem = async ({ user, sessionId }: { user: IUser, sessionId: string | undefined }) => { const isFollowing = following({ user, sessionUserId: sessionId ? sessionId : "", @@ -27,11 +27,14 @@ export const UserItem = ({ user, sessionId }: { user: IUser, sessionId: string | <h1 className="text-sm text-sky-500">@{user.username}</h1> </div> - <FollowButton - userId={user.id} - username={user.username ? user.username : ""} - isFollowing={isFollowing} - /> + {/* TODO does not refresh button when following or unfolling */} + {/* {sessionId && sessionId !== user.id && + <FollowButton + userId={user.id} + username={user.username ? user.username : ""} + isFollowing={isFollowing} + /> + } */} </div> {user.bio ? (<p className="truncate w-full">{user.bio}</p>) : <p> </p>}