38 lines
1000 B
TypeScript
38 lines
1000 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { SkillsService } from "@/services/skills-service";
|
|
|
|
export async function PUT(
|
|
request: NextRequest,
|
|
{ params }: { params: { skillId: string } }
|
|
) {
|
|
try {
|
|
const { importance } = await request.json();
|
|
const { skillId } = params;
|
|
|
|
// Validation
|
|
if (
|
|
!importance ||
|
|
!["incontournable", "majeure", "standard"].includes(importance)
|
|
) {
|
|
return NextResponse.json(
|
|
{
|
|
error:
|
|
"Importance invalide. Doit être 'incontournable', 'majeure' ou 'standard'",
|
|
},
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
// Mettre à jour l'importance
|
|
await SkillsService.updateSkillImportance(skillId, importance);
|
|
|
|
return NextResponse.json({ success: true });
|
|
} catch (error) {
|
|
console.error("Error updating skill importance:", error);
|
|
return NextResponse.json(
|
|
{ error: "Erreur lors de la mise à jour de l'importance" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|