- Updated GET handler in auth route to fetch user UUID from cookie using AuthService. - Improved error handling for unauthenticated and non-existent users. - Added team name retrieval for the user profile, with fallback handling. - Refactored AuthClient to return detailed user information including team details. - Enhanced navigation component to use a dropdown menu for user actions, improving UI/UX. - Implemented loading state in UserContext to manage user info fetching.
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { AuthService, userService, TeamsService } from "@/services";
|
|
import { AccountForm } from "@/components/account/account-form";
|
|
|
|
export default async function AccountPage() {
|
|
try {
|
|
// Vérifier si l'utilisateur est connecté
|
|
const userUuid = await AuthService.getUserUuidFromCookie();
|
|
|
|
if (!userUuid) {
|
|
redirect("/login");
|
|
}
|
|
|
|
// Récupérer le profil utilisateur
|
|
const userProfile = await userService.getUserByUuid(userUuid);
|
|
|
|
if (!userProfile) {
|
|
redirect("/login");
|
|
}
|
|
|
|
// Charger les équipes pour la sélection
|
|
const teams = await TeamsService.getTeams();
|
|
|
|
return (
|
|
<div className="container mx-auto px-4 py-8">
|
|
<div className="max-w-2xl mx-auto">
|
|
<h1 className="text-3xl font-bold mb-8">Mon compte</h1>
|
|
<AccountForm initialProfile={userProfile} teams={teams} />
|
|
</div>
|
|
</div>
|
|
);
|
|
} catch (error) {
|
|
console.error("Error loading account page:", error);
|
|
redirect("/login");
|
|
}
|
|
}
|