// This file handles the API route for fetching scheduled appointments for doctors.
export async function GET(req) {
  try {
    const res = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/appointmentbooking/doctor/scheduled`, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        cookie: req.headers.get('cookie') || '',
      },
    });

    if (!res.ok) {
      const errorData = await res.json();
      return new Response(JSON.stringify({ error: errorData.error || 'Failed to fetch scheduled appointments' }), {
        status: res.status,
      });
    }

    const result = await res.json();
    return new Response(JSON.stringify(result), { status: 200 });
  } catch (error) {
    console.error('Error fetching doctor scheduled appointments:', error);
    return new Response(JSON.stringify({ error: 'Internal server error' }), { status: 500 });
  }
}
