Files
got-gaming/app/profile/page.tsx

47 lines
1.1 KiB
TypeScript

import { redirect } from "next/navigation";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { getBackgroundImage } from "@/lib/preferences";
import NavigationWrapper from "@/components/NavigationWrapper";
import ProfileForm from "@/components/ProfileForm";
export default async function ProfilePage() {
const session = await auth();
if (!session?.user) {
redirect("/login");
}
const user = await prisma.user.findUnique({
where: { id: session.user.id },
select: {
id: true,
email: true,
username: true,
avatar: true,
bio: true,
hp: true,
maxHp: true,
xp: true,
maxXp: true,
level: true,
score: true,
createdAt: true,
},
});
if (!user) {
redirect("/login");
}
const backgroundImage = await getBackgroundImage("home", "/got-background.jpg");
return (
<main className="min-h-screen bg-black relative">
<NavigationWrapper />
<ProfileForm initialProfile={user} backgroundImage={backgroundImage} />
</main>
);
}