All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m36s
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { auth } from "@/lib/auth";
|
|
import { userService } from "@/services/users/user.service";
|
|
import { getBackgroundImage } from "@/lib/preferences";
|
|
import NavigationWrapper from "@/components/navigation/NavigationWrapper";
|
|
import ProfileForm from "@/components/profile/ProfileForm";
|
|
|
|
export default async function ProfilePage() {
|
|
const session = await auth();
|
|
|
|
if (!session?.user) {
|
|
redirect("/login");
|
|
}
|
|
|
|
const user = await userService.getUserById(session.user.id, {
|
|
id: true,
|
|
email: true,
|
|
username: true,
|
|
avatar: true,
|
|
bio: true,
|
|
characterClass: 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"
|
|
);
|
|
|
|
// Convert Date to string for the component
|
|
const userProfile = {
|
|
...user,
|
|
createdAt: user.createdAt.toISOString(),
|
|
};
|
|
|
|
return (
|
|
<main className="min-h-screen bg-black relative">
|
|
<NavigationWrapper />
|
|
<ProfileForm
|
|
initialProfile={userProfile}
|
|
backgroundImage={backgroundImage}
|
|
/>
|
|
</main>
|
|
);
|
|
}
|