import { NextRequest, NextResponse } from "next/server";
import bcrypt from "bcryptjs";
import { prisma } from "@/lib/prisma";
import { getStudent } from "@/lib/studentAuth";

export async function GET() {
    const auth: any = await getStudent();
    if (!auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });

    const student = await prisma.students.findUnique({
        where: { id: auth.id },
        select: {
            id: true,
            student_id: true,
            name: true,
            contact: true,
            email: true,
        },
    });

    if (!student) return NextResponse.json({ error: "Student not found" }, { status: 404 });

    return NextResponse.json({ data: student });
}