refactor: revew all design of services, clients, deadcode, ...
This commit is contained in:
@@ -1,15 +1,6 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
export default async function ManageAdminPage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Rediriger vers la page skills par défaut
|
||||
redirect("/admin/manage/skills");
|
||||
}
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
import { AdminService } from "@/services/admin-service";
|
||||
import { SkillsManagementPage } from "@/components/admin/skills";
|
||||
|
||||
export default async function SkillsPage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les données côté serveur
|
||||
try {
|
||||
const adminData = await AdminService.getAdminData();
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
import { AdminService } from "@/services/admin-service";
|
||||
import { TeamsManagementPage } from "@/components/admin/teams";
|
||||
|
||||
export default async function TeamsPage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les données côté serveur
|
||||
try {
|
||||
const adminData = await AdminService.getAdminData();
|
||||
|
||||
@@ -1,26 +1,12 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
import { AdminService } from "@/services/admin-service";
|
||||
import { UsersManagementPage } from "@/components/admin/users";
|
||||
|
||||
export default async function UsersPage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les données côté serveur
|
||||
try {
|
||||
const adminData = await AdminService.getAdminData();
|
||||
|
||||
return (
|
||||
<UsersManagementPage
|
||||
teams={adminData.teams}
|
||||
/>
|
||||
);
|
||||
return <UsersManagementPage teams={adminData.teams} />;
|
||||
} catch (error) {
|
||||
console.error("Failed to load admin data:", error);
|
||||
return (
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
import { AdminService } from "@/services/admin-service";
|
||||
import { AdminClientWrapper } from "@/components/admin";
|
||||
|
||||
export default async function AdminPage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les données côté serveur
|
||||
try {
|
||||
const adminData = await AdminService.getAdminData();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
import { AdminService, TeamStats } from "@/services/admin-service";
|
||||
import { AdminService } from "@/services/admin-service";
|
||||
import { TeamDetailClientWrapper } from "@/components/admin";
|
||||
|
||||
interface TeamDetailPageProps {
|
||||
@@ -13,14 +12,6 @@ export default async function TeamDetailPage({ params }: TeamDetailPageProps) {
|
||||
// Await params before using
|
||||
const { teamId } = await params;
|
||||
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
try {
|
||||
// Charger les données côté serveur
|
||||
const allTeamsStats = await AdminService.getTeamsStats();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getPool } from "@/services/database";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
// Configuration pour éviter la génération statique
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -8,12 +7,6 @@ export const dynamic = "force-dynamic";
|
||||
// GET - Récupérer toutes les skills
|
||||
export async function GET() {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const pool = getPool();
|
||||
const query = `
|
||||
SELECT
|
||||
@@ -56,12 +49,6 @@ export async function GET() {
|
||||
// POST - Créer une nouvelle skill
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { name, categoryId, description, icon } = await request.json();
|
||||
|
||||
if (!name || !categoryId) {
|
||||
@@ -125,12 +112,6 @@ export async function POST(request: NextRequest) {
|
||||
// PUT - Mettre à jour une skill
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { id, name, categoryId, description, icon } = await request.json();
|
||||
|
||||
if (!id || !name || !categoryId) {
|
||||
@@ -204,12 +185,6 @@ export async function PUT(request: NextRequest) {
|
||||
// DELETE - Supprimer une skill
|
||||
export async function DELETE(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get("id");
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getPool } from "@/services/database";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
// GET - Récupérer les membres d'une équipe
|
||||
export async function GET(
|
||||
@@ -8,12 +7,6 @@ export async function GET(
|
||||
{ params }: { params: Promise<{ teamId: string }> }
|
||||
) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { teamId } = await params;
|
||||
|
||||
if (!teamId) {
|
||||
@@ -61,12 +54,6 @@ export async function DELETE(
|
||||
{ params }: { params: Promise<{ teamId: string }> }
|
||||
) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { teamId } = await params;
|
||||
const { memberId } = await request.json();
|
||||
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getPool } from "@/services/database";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
// GET - Récupérer toutes les teams
|
||||
export async function GET() {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const pool = getPool();
|
||||
const query = `
|
||||
SELECT
|
||||
@@ -46,12 +39,6 @@ export async function GET() {
|
||||
// POST - Créer une nouvelle team
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { name, direction } = await request.json();
|
||||
|
||||
if (!name || !direction) {
|
||||
@@ -106,12 +93,6 @@ export async function POST(request: NextRequest) {
|
||||
// PUT - Mettre à jour une team
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { id, name, direction } = await request.json();
|
||||
|
||||
if (!id || !name || !direction) {
|
||||
@@ -187,12 +168,6 @@ export async function PUT(request: NextRequest) {
|
||||
// DELETE - Supprimer une team ou une direction
|
||||
export async function DELETE(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const id = searchParams.get("id");
|
||||
const direction = searchParams.get("direction");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getPool } from "@/services/database";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
// DELETE - Supprimer complètement un utilisateur
|
||||
export async function DELETE(
|
||||
@@ -8,12 +7,6 @@ export async function DELETE(
|
||||
{ params }: { params: Promise<{ userId: string }> }
|
||||
) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { userId } = await params;
|
||||
|
||||
if (!userId) {
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getPool } from "@/services/database";
|
||||
import { isUserAuthenticated } from "@/lib/server-auth";
|
||||
|
||||
// GET - Récupérer la liste des utilisateurs
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
return NextResponse.json({ error: "Non autorisé" }, { status: 401 });
|
||||
}
|
||||
|
||||
const pool = getPool();
|
||||
|
||||
// Récupérer tous les utilisateurs avec leurs informations d'équipe et d'évaluations
|
||||
|
||||
@@ -3,12 +3,11 @@ import { cookies } from "next/headers";
|
||||
import { evaluationService } from "@/services/evaluation-service";
|
||||
import { userService } from "@/services/user-service";
|
||||
import { UserEvaluation, UserProfile } from "@/lib/types";
|
||||
import { COOKIE_NAME } from "@/lib/auth-utils";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const cookieStore = await cookies();
|
||||
const userUuid = cookieStore.get(COOKIE_NAME)?.value;
|
||||
const userUuid = cookieStore.get("peakSkills_userId")?.value;
|
||||
|
||||
// Support pour l'ancien mode avec paramètres (pour la compatibilité)
|
||||
if (!userUuid) {
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import {
|
||||
isUserAuthenticated,
|
||||
getServerUserEvaluation,
|
||||
getServerSkillCategories,
|
||||
getServerTeams,
|
||||
} from "@/lib/server-auth";
|
||||
import { AuthService } from "@/services";
|
||||
import { SkillsService, TeamsService } from "@/services";
|
||||
import { evaluationService } from "@/services/evaluation-service";
|
||||
import { EvaluationClientWrapper } from "@/components/evaluation";
|
||||
import { SkillEvaluation } from "@/components/skill-evaluation";
|
||||
|
||||
export default async function EvaluationPage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
// Charger les données côté serveur
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
if (!userUuid) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les données côté serveur
|
||||
const [userEvaluation, skillCategories, teams] = await Promise.all([
|
||||
getServerUserEvaluation(),
|
||||
getServerSkillCategories(),
|
||||
getServerTeams(),
|
||||
evaluationService.getServerUserEvaluation(userUuid!),
|
||||
SkillsService.getSkillCategories(),
|
||||
TeamsService.getTeams(),
|
||||
]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,265 +1,46 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { ProfileForm } from "@/components/profile-form";
|
||||
import { AuthService } from "@/lib/auth-utils";
|
||||
import { UserProfile, Team } from "@/lib/types";
|
||||
import { Code2, LogOut, Edit, X, Home } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { redirect } from "next/navigation";
|
||||
import { TeamsService, userService } from "@/services";
|
||||
import { AuthService } from "@/services";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import Link from "next/link";
|
||||
LoginLayout,
|
||||
LoginFormWrapper,
|
||||
LoginLoading,
|
||||
} from "@/components/login";
|
||||
|
||||
interface LoginPageProps {}
|
||||
export default async function LoginPage() {
|
||||
try {
|
||||
// Charger les équipes côté serveur
|
||||
const teams = await TeamsService.getTeams();
|
||||
|
||||
export default function LoginPage({}: LoginPageProps) {
|
||||
const [teams, setTeams] = useState<Team[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [authenticating, setAuthenticating] = useState(false);
|
||||
const [currentUser, setCurrentUser] = useState<UserProfile | null>(null);
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const router = useRouter();
|
||||
// Vérifier si l'utilisateur est déjà connecté
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
useEffect(() => {
|
||||
async function initialize() {
|
||||
try {
|
||||
// Vérifier si l'utilisateur est déjà connecté
|
||||
const user = await AuthService.getCurrentUser();
|
||||
setCurrentUser(user);
|
||||
if (userUuid) {
|
||||
// Si l'utilisateur est connecté, récupérer son profil côté serveur
|
||||
const userProfile = await userService.getUserByUuid(userUuid);
|
||||
|
||||
// Charger les équipes
|
||||
const teamsResponse = await fetch("/api/teams");
|
||||
if (teamsResponse.ok) {
|
||||
const teamsData = await teamsResponse.json();
|
||||
setTeams(teamsData);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error initializing login page:", error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
if (userProfile) {
|
||||
// Passer le profil utilisateur pour permettre la modification
|
||||
return (
|
||||
<LoginLayout>
|
||||
<LoginFormWrapper teams={teams} initialUser={userProfile} />
|
||||
</LoginLayout>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
initialize();
|
||||
}, []);
|
||||
|
||||
const handleSubmit = async (profile: UserProfile) => {
|
||||
setAuthenticating(true);
|
||||
try {
|
||||
await AuthService.login(profile);
|
||||
if (isEditing) {
|
||||
// Si on modifie le profil existant, mettre à jour l'état
|
||||
setCurrentUser(profile);
|
||||
setIsEditing(false);
|
||||
} else {
|
||||
// Si c'est un nouveau login, rediriger
|
||||
router.push("/");
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Login failed:", error);
|
||||
// Vous pouvez ajouter une notification d'erreur ici
|
||||
} finally {
|
||||
setAuthenticating(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
await AuthService.logout();
|
||||
setCurrentUser(null);
|
||||
setIsEditing(false);
|
||||
} catch (error) {
|
||||
console.error("Logout failed:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const handleEdit = () => {
|
||||
setIsEditing(true);
|
||||
};
|
||||
|
||||
const handleCancelEdit = () => {
|
||||
setIsEditing(false);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
// Si l'utilisateur n'est pas connecté, afficher le formulaire de connexion
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 relative overflow-hidden">
|
||||
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-blue-900/20 via-slate-900 to-slate-950" />
|
||||
<div className="absolute inset-0 bg-grid-white/5 bg-[size:50px_50px]" />
|
||||
|
||||
<div className="relative z-10 container mx-auto py-16 px-6">
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<div className="text-center">
|
||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-400 mx-auto mb-4"></div>
|
||||
<p className="text-white">Chargement...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<LoginLayout>
|
||||
<LoginFormWrapper teams={teams} />
|
||||
</LoginLayout>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Error loading login page:", error);
|
||||
return (
|
||||
<LoginLayout>
|
||||
<LoginLoading />
|
||||
</LoginLayout>
|
||||
);
|
||||
}
|
||||
|
||||
// Si l'utilisateur est connecté et qu'on ne modifie pas
|
||||
if (currentUser && !isEditing) {
|
||||
const currentTeam = teams.find((t) => t.id === currentUser.teamId);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 relative overflow-hidden">
|
||||
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-blue-900/20 via-slate-900 to-slate-950" />
|
||||
<div className="absolute inset-0 bg-grid-white/5 bg-[size:50px_50px]" />
|
||||
|
||||
<div className="relative z-10 container mx-auto py-16 px-6">
|
||||
<div className="text-center mb-12">
|
||||
<div className="inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/5 border border-white/10 backdrop-blur-sm mb-6">
|
||||
<Code2 className="h-4 w-4 text-blue-400" />
|
||||
<span className="text-sm font-medium text-slate-200">
|
||||
PeakSkills
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="text-4xl font-bold mb-4 text-white">
|
||||
Vous êtes connecté
|
||||
</h1>
|
||||
<p className="text-lg text-slate-400 mb-8">
|
||||
Gérez votre profil ou retournez à l'application
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="max-w-2xl mx-auto space-y-6">
|
||||
{/* Informations utilisateur */}
|
||||
<Card className="bg-white/5 border-white/10 backdrop-blur-sm">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-white">Vos informations</CardTitle>
|
||||
<CardDescription className="text-slate-400">
|
||||
Profil actuellement connecté
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-300">
|
||||
Prénom
|
||||
</label>
|
||||
<p className="text-white">{currentUser.firstName}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-300">
|
||||
Nom
|
||||
</label>
|
||||
<p className="text-white">{currentUser.lastName}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium text-slate-300">
|
||||
Équipe
|
||||
</label>
|
||||
<p className="text-white">
|
||||
{currentTeam?.name || "Équipe non trouvée"}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex gap-4 justify-center">
|
||||
<Button
|
||||
onClick={() => router.push("/")}
|
||||
className="bg-blue-500 hover:bg-blue-600 text-white"
|
||||
>
|
||||
<Home className="w-4 h-4 mr-2" />
|
||||
Retour à l'accueil
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleEdit}
|
||||
variant="outline"
|
||||
className="border-white/20 text-white hover:bg-white/10"
|
||||
>
|
||||
<Edit className="w-4 h-4 mr-2" />
|
||||
Modifier le profil
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleLogout}
|
||||
variant="outline"
|
||||
className="border-red-500/50 text-red-400 hover:bg-red-500/10"
|
||||
>
|
||||
<LogOut className="w-4 h-4 mr-2" />
|
||||
Se déconnecter
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Sinon, afficher le formulaire (nouvel utilisateur ou modification)
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 relative overflow-hidden">
|
||||
<div className="absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-blue-900/20 via-slate-900 to-slate-950" />
|
||||
<div className="absolute inset-0 bg-grid-white/5 bg-[size:50px_50px]" />
|
||||
|
||||
<div className="relative z-10 container mx-auto py-16 px-6">
|
||||
<div className="text-center mb-12">
|
||||
<div className="inline-flex items-center gap-2 px-4 py-2 rounded-full bg-white/5 border border-white/10 backdrop-blur-sm mb-6">
|
||||
<Code2 className="h-4 w-4 text-blue-400" />
|
||||
<span className="text-sm font-medium text-slate-200">
|
||||
PeakSkills
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="text-4xl font-bold mb-4 text-white">
|
||||
{isEditing
|
||||
? "Modifier vos informations"
|
||||
: "Bienvenue sur PeakSkills"}
|
||||
</h1>
|
||||
<p className="text-lg text-slate-400 mb-8">
|
||||
{isEditing
|
||||
? "Mettez à jour vos informations personnelles"
|
||||
: "Évaluez vos compétences techniques et suivez votre progression"}
|
||||
</p>
|
||||
|
||||
{isEditing && (
|
||||
<Button
|
||||
onClick={handleCancelEdit}
|
||||
variant="outline"
|
||||
className="mb-8 border-white/20 text-white hover:bg-white/10"
|
||||
>
|
||||
<X className="w-4 h-4 mr-2" />
|
||||
Annuler
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<div className="relative">
|
||||
{authenticating && (
|
||||
<div className="absolute inset-0 bg-black/20 backdrop-blur-sm z-10 flex items-center justify-center rounded-lg">
|
||||
<div className="text-center">
|
||||
<div className="animate-spin rounded-full h-6 w-6 border-b-2 border-blue-400 mx-auto mb-2"></div>
|
||||
<p className="text-white text-sm">
|
||||
{isEditing
|
||||
? "Mise à jour en cours..."
|
||||
: "Connexion en cours..."}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<ProfileForm
|
||||
teams={teams}
|
||||
onSubmit={handleSubmit}
|
||||
initialProfile={
|
||||
isEditing && currentUser ? currentUser : undefined
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
22
app/page.tsx
22
app/page.tsx
@@ -1,10 +1,6 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import {
|
||||
isUserAuthenticated,
|
||||
getServerUserEvaluation,
|
||||
getServerSkillCategories,
|
||||
getServerTeams,
|
||||
} from "@/lib/server-auth";
|
||||
import { AuthService } from "@/services";
|
||||
import { evaluationService, SkillsService, TeamsService } from "@/services";
|
||||
import { generateRadarData } from "@/lib/evaluation-utils";
|
||||
import {
|
||||
WelcomeHeader,
|
||||
@@ -16,19 +12,17 @@ import {
|
||||
} from "@/components/home";
|
||||
|
||||
export default async function HomePage() {
|
||||
// Vérifier l'authentification
|
||||
const isAuthenticated = await isUserAuthenticated();
|
||||
// Charger les données côté serveur
|
||||
const userUuid = await AuthService.getUserUuidFromCookie();
|
||||
|
||||
// Si pas de cookie d'authentification, rediriger vers login
|
||||
if (!isAuthenticated) {
|
||||
if (!userUuid) {
|
||||
redirect("/login");
|
||||
}
|
||||
|
||||
// Charger les données côté serveur
|
||||
const [userEvaluation, skillCategories, teams] = await Promise.all([
|
||||
getServerUserEvaluation(),
|
||||
getServerSkillCategories(),
|
||||
getServerTeams(),
|
||||
evaluationService.getServerUserEvaluation(userUuid!),
|
||||
SkillsService.getSkillCategories(),
|
||||
TeamsService.getTeams(),
|
||||
]);
|
||||
|
||||
// Si pas d'évaluation, afficher l'écran d'accueil
|
||||
|
||||
Reference in New Issue
Block a user