import { ReactNode } from "react"; import Image from "next/image"; import { Button } from "@/modules/common/components/button"; import { fetchCurrentUser } from "@/modules/features/auth/fetch/fetchCurrentUser"; import { FollowButton } from "@/modules/features/profile/components/followButton"; import { fetchProfile } from "@/modules/features/profile/fetch/fetchProfile"; import { getSession } from "@/utils/auth/session"; import { showEditProfileSettingsButton, showFollowButton } from "./_functions"; type Props = { children: ReactNode; params: Promise<{ username: string; }>; }; const Layout = async ({ children, params }: Props) => { const profile = await fetchProfile((await params).username); const currentUser = (await getSession()) ? await fetchCurrentUser() : undefined; return (
{profile.image && }

{profile.username}

{profile.bio &&

{profile.bio}

} {showFollowButton(profile.username, currentUser) && } {showEditProfileSettingsButton(profile.username, currentUser) && ( )}
{children}
); }; export default Layout;