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"); } // Paralléliser les appels DB const [user, backgroundImage] = await Promise.all([ 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, }), getBackgroundImage("profile", "/got-background.jpg"), ]); if (!user) { redirect("/login"); } // Convert Date to string for the component const userProfile = { ...user, createdAt: user.createdAt.toISOString(), }; return (
); }