diff --git a/src/app/profile/[id]/page.tsx b/src/app/profile/[id]/page.tsx index 91c898e..1fb8ba3 100644 --- a/src/app/profile/[id]/page.tsx +++ b/src/app/profile/[id]/page.tsx @@ -77,8 +77,8 @@ export default async function ProfilePage({ params }: Props) { return (
- - + +
); } diff --git a/src/app/profile/settings/page.tsx b/src/app/profile/settings/page.tsx index 4d0b255..0a32a2a 100644 --- a/src/app/profile/settings/page.tsx +++ b/src/app/profile/settings/page.tsx @@ -2,7 +2,6 @@ import { Metadata } from "next"; import { redirect } from "next/navigation"; import { auth } from "@/lib/auth"; -import { prisma } from "@/lib/prisma"; import ProfileSettings from "@/components/profile-settings"; import ProfileInformation from "@/components/profile-information"; @@ -21,11 +20,9 @@ export default async function ProfileSettingsPage() { if (!session) redirect("/login"); - const userExtra = await prisma.user.findUnique({ where: { id: Number(session.user.id) } }); - return (
- +
); diff --git a/src/components/profile-information.tsx b/src/components/profile-information.tsx index 6c59df7..88d4b38 100644 --- a/src/components/profile-information.tsx +++ b/src/components/profile-information.tsx @@ -1,31 +1,30 @@ +import Link from "next/link"; import Image from "next/image"; -import { User } from "@prisma/client"; import { Icon } from "@iconify/react"; import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; -import Link from "next/link"; interface Props { - user?: User; - createdAt: Date; + userId?: number; inSettings?: boolean; } -export default async function ProfileInformation({ user: userData, createdAt, inSettings }: Props) { +export default async function ProfileInformation({ userId, inSettings }: Props) { const session = await auth(); - const id = userData && userData.id ? userData.id : Number(session?.user.id); - const user = userData ? userData : session?.user; - + 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; + return (
{/* Profile picture */} profile picture

- {user?.name} + {user.name} {id === Number(process.env.NEXT_PUBLIC_ADMIN_USER_ID) && (
@@ -51,8 +50,8 @@ export default async function ProfileInformation({ user: userData, createdAt, in

Liked {likedMiis} Miis

-

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

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