import { type NextRequest, NextResponse } from "next/server" import { register } from "@/lib/auth" export async function POST(request: NextRequest) { try { const userData = await request.json() if (!userData.name || !userData.email || !userData.password) { return NextResponse.json({ error: "جميع الحقول المطلوبة يجب ملؤها" }, { status: 400 }) } const user = await register(userData) return NextResponse.json({ message: "تم إنشاء الحساب بنجاح", user: { id: user.id, name: user.name, email: user.email, role: user.role }, }) } catch (error) { return NextResponse.json({ error: "حدث خطأ في إنشاء الحساب" }, { status: 500 }) } }