// /api/visit-type-rates/provider-data.ts
import { NextRequest, NextResponse } from 'next/server';
import { getDBConnection } from '@/lib/db'; // adjust path as needed


export async function GET(request: NextRequest) {
  const companyId = request.nextUrl.searchParams.get('companyId');

  if (!companyId ) {
    return NextResponse.json({ error: 'Missing companyId or doctorId' }, { status: 400 });
  }

  try {
    const connection = await getDBConnection();

    const [visitTypesWithRates] = await connection.execute(
      `SELECT * from visit_type where company_id = ?`,
      [ companyId]
    );

    await connection.end();

    return NextResponse.json({
      visitTypesWithRates,
    });
  } catch (error) {
    // console.error('Error fetching provider data:', error);
    return NextResponse.json({ error }, { status: 500 });
  }
}
