diff --git a/src/app/(web)/account/page.jsx b/src/app/(web)/account/page.jsx index 862a308..aecc627 100644 --- a/src/app/(web)/account/page.jsx +++ b/src/app/(web)/account/page.jsx @@ -56,13 +56,18 @@ const AccountPage = () => { }; const handleSave = async () => { - await axios.put(`/api/patients/${selectedPatient.email}`, { + try { + await axios.put(`/api/patients?email=${selectedPatient.email}`, { medications, medicalConditions: diagnoses, - }); - alert('Patient data updated successfully'); + }); + alert('Patient data updated successfully'); + } catch (error) { + console.error('Error updating patient data:', error); + alert('Failed to update patient data'); + } }; - + if (!userData) return
Loading...
; return ( diff --git a/src/app/api/patients/route.js b/src/app/api/patients/route.js index c1f0c5d..306b031 100644 --- a/src/app/api/patients/route.js +++ b/src/app/api/patients/route.js @@ -20,13 +20,14 @@ export async function GET() { } } -export async function PUT(req, { params }) { +export async function PUT(req) { console.log('Processing patient update request...'); await connectDB(); try { - const { email } = params; + const url = new URL(req.url); + const email = url.searchParams.get('email'); if (!email) { console.log('No email provided');