- 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.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { SkillsService } from "@/services";
|
|
|
|
export async function GET() {
|
|
try {
|
|
const skillCategories = await SkillsService.getSkillCategories();
|
|
return NextResponse.json(skillCategories);
|
|
} catch (error) {
|
|
console.error("Error loading skills:", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to load skills" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const categoryData: { id: string; name: string; icon: string } =
|
|
await request.json();
|
|
|
|
// Validate required fields
|
|
if (!categoryData.id || !categoryData.name || !categoryData.icon) {
|
|
return NextResponse.json(
|
|
{ error: "Missing required fields: id, name, icon" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
await SkillsService.createSkillCategory(categoryData);
|
|
return NextResponse.json({ success: true }, { status: 201 });
|
|
} catch (error) {
|
|
console.error("Error creating skill category:", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to create skill category" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|