feat: remove a skill category empty
This commit is contained in:
39
app/api/admin/skills/categories/[categoryId]/route.ts
Normal file
39
app/api/admin/skills/categories/[categoryId]/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { AdminService } from "@/services/admin-service";
|
||||
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { categoryId: string } }
|
||||
) {
|
||||
try {
|
||||
const { categoryId } = params;
|
||||
|
||||
if (!categoryId) {
|
||||
return NextResponse.json(
|
||||
{ error: "ID de catégorie requis" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await AdminService.deleteSkillCategory(categoryId);
|
||||
|
||||
return NextResponse.json(
|
||||
{ message: "Catégorie supprimée avec succès" },
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Erreur lors de la suppression de la catégorie:", error);
|
||||
|
||||
if (error instanceof Error) {
|
||||
return NextResponse.json(
|
||||
{ error: error.message },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
return NextResponse.json(
|
||||
{ error: "Erreur interne du serveur" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user