From 111caa738c4f11ad6be037ba25e4d22351cd386d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20Akg=C3=BCl?= <s86116@bht-berlin.de> Date: Sun, 9 Jul 2023 16:27:12 +0200 Subject: [PATCH] idk anymore put it in issues --- .../(user)/[username]/followers/page.tsx | 27 ++++++++++++++++--- .../profile/components/user-follows.tsx | 26 +++++++++++++++--- components/profile/components/user-item.tsx | 15 ++++++----- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/app/(content)/(user)/[username]/followers/page.tsx b/app/(content)/(user)/[username]/followers/page.tsx index 5ea8f4d..861d82f 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 afd3d0f..69daa9a 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 8a8f81d..20fa31d 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>} -- GitLab