export async function POST(req) {
  try {
    const body = await req.json();

    const response = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/consultationassign/`, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        cookie: req.headers.get("cookie") || "",
      },
      body: JSON.stringify({
        consultationId: body.consultationId,
        doctorId: body.doctorId,
      }),
    });

    if (!response.ok) {
      throw new Error('Failed to assign consultation');
    }

    const data = await response.json();
    return new Response(JSON.stringify(data), { status: 200 });
  } catch (error) {
    console.error('Error assigning consultation:', error);
    return new Response(JSON.stringify({ error: 'Internal server error' }), { status: 500 });
  }
}
