import Link from "next/link"; import { Icon } from "@iconify/react"; import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; import ProfilePicture from "./profile-picture"; import Description from "./description"; interface Props { userId?: number; page?: "settings" | "likes"; } export default async function ProfileInformation({ userId, page }: Props) { const session = await auth(); const id = userId ? userId : Number(session?.user.id); const user = await prisma.user.findUnique({ where: { id } }); const likedMiis = await prisma.like.count({ where: { userId: id } }); if (!user) return null; const isAdmin = id === Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID); const isContributor = process.env.NEXT_PUBLIC_CONTRIBUTORS_USER_IDS?.split(",").includes(id.toString()); const isOwnProfile = Number(session?.user.id) === id; return (
{/* Profile picture */} {/* User information */}

{user.name}

{isAdmin && (
)} {isContributor && (
)}

@{user?.username}

Created: {user.createdAt.toLocaleDateString("en-GB", { month: "long", day: "2-digit", year: "numeric" })}

Liked {likedMiis} Miis

{user.description && }
{/* Buttons */}
{!isOwnProfile && ( Report )} {isOwnProfile && isAdmin && ( Admin )} {isOwnProfile && page !== "likes" && ( My Likes )} {isOwnProfile && page !== "settings" && ( Settings )} {page && ( Back )}
); }