refactor: remove legacy evaluation route and update user management interfaces

- Deleted the obsolete evaluations route to streamline the API.
- Added User and UserFormData interfaces to admin-client for better user management.
- Updated useUsersManagement hook to utilize adminClient for fetching and creating users, improving data handling.
- Cleaned up unused imports and code for better maintainability.
This commit is contained in:
Julien Froidefond
2025-08-25 08:30:34 +02:00
parent 26496e7473
commit dc06f00342
5 changed files with 27 additions and 97 deletions

View File

@@ -1,73 +0,0 @@
import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
import { evaluationService } from "@/services/evaluation-service";
import { userService } from "@/services/user-service";
import { UserEvaluation, UserProfile } from "@/lib/types";
export async function GET(request: NextRequest) {
try {
const cookieStore = await cookies();
const userUuid = cookieStore.get("peakSkills_userId")?.value;
// Support pour l'ancien mode avec paramètres (pour la compatibilité)
if (!userUuid) {
const { searchParams } = new URL(request.url);
const firstName = searchParams.get("firstName");
const lastName = searchParams.get("lastName");
const teamId = searchParams.get("teamId");
if (!firstName || !lastName || !teamId) {
return NextResponse.json(
{ error: "Utilisateur non authentifié" },
{ status: 401 }
);
}
const profile: UserProfile = { firstName, lastName, teamId };
const evaluation = await evaluationService.loadUserEvaluation(profile);
return NextResponse.json({ evaluation });
}
// Mode authentifié par cookie UUID
const userProfile = await userService.getUserByUuid(userUuid);
if (!userProfile) {
return NextResponse.json(
{ error: "Utilisateur non trouvé" },
{ status: 404 }
);
}
const evaluation = await evaluationService.loadUserEvaluation(userProfile);
return NextResponse.json({ evaluation });
} catch (error) {
console.error("Erreur lors du chargement de l'évaluation:", error);
return NextResponse.json(
{ error: "Erreur interne du serveur" },
{ status: 500 }
);
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const evaluation: UserEvaluation = body.evaluation;
if (!evaluation || !evaluation.profile) {
return NextResponse.json(
{ error: "Évaluation invalide" },
{ status: 400 }
);
}
await evaluationService.saveUserEvaluation(evaluation);
return NextResponse.json({ success: true });
} catch (error) {
console.error("Erreur lors de la sauvegarde de l'évaluation:", error);
return NextResponse.json(
{ error: "Erreur interne du serveur" },
{ status: 500 }
);
}
}

View File

@@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
import { evaluationService } from "@/services/evaluation-service";
import { userService } from "@/services/user-service";
import { UserProfile, SkillLevel } from "@/lib/types";
const COOKIE_NAME = "peakSkills_userId";