/* eslint-disable -- temporary disable for development/testing purposes */

import { NextRequest, NextResponse } from 'next/server';
import { getDBConnection } from '@/lib/db'; // adjust path as needed

export async function GET(req: NextRequest, { params }: { params: { id: string } }) {
 
  const patientId = params.id;
  // console.log('Patient ID:', patientId);
  try {
    const connection = await getDBConnection();

    const [userRows]: any = await connection.execute(
        'SELECT * FROM users WHERE id = ?',
        [patientId]
      );
      const user = Array.isArray(userRows) && userRows.length > 0 ? userRows[0] : null;
      

    

    await connection.end();

    return NextResponse.json({
        user,
      
    });
  } catch (error) {
    // console.error(error);
    return NextResponse.json({ error: 'Failed to fetch patient details' }, { status: 500 });
  }
}
