// app/api/updatepatientnotes/route.js

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

    const res = await fetch(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/updatepatientnotes`, {
      method: 'POST', 
      headers: {
        'Content-Type': 'application/json',
        cookie: req.headers.get('cookie') || '',
      },
      credentials: 'include',
      body: JSON.stringify(body),
    });

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

    const data = await res.json();
    return new Response(JSON.stringify(data), { status: 200 });
  } catch (error) {
    console.error('Update notes error:', error);
    return new Response(JSON.stringify({ error: error.message }), { status: 500 });
  }
}
