From 67a5e145e0c33e638b8e7e4b1e7300200dafb8c9 Mon Sep 17 00:00:00 2001 From: Joseph J Helfenbein Date: Sat, 25 Jan 2025 06:55:56 -0500 Subject: [PATCH] add console logs --- src/app/api/patients/[email].js | 7 +++++++ src/app/api/user.js | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/api/patients/[email].js b/src/app/api/patients/[email].js index 4e97c58..c4003a2 100644 --- a/src/app/api/patients/[email].js +++ b/src/app/api/patients/[email].js @@ -7,9 +7,14 @@ export default async (req, res) => { const { email } = req.query; const { medications, medicalConditions } = req.body; + console.log('Received request to update patient with email:', email); + console.log('Medications:', medications); + console.log('Medical Conditions:', medicalConditions); + const patient = await User.findOne({ email }); if (!patient) { + console.log('Patient not found for email:', email); return res.status(404).json({ message: 'Patient not found' }); } @@ -17,5 +22,7 @@ export default async (req, res) => { patient.medicalConditions = medicalConditions; await patient.save(); + console.log('Patient data updated successfully:', patient); + res.json(patient); }; \ No newline at end of file diff --git a/src/app/api/user.js b/src/app/api/user.js index 29ee285..4096003 100644 --- a/src/app/api/user.js +++ b/src/app/api/user.js @@ -5,24 +5,32 @@ export default async (req, res) => { await connectDB(); const { userId } = req.query; + console.log('Received request with userId:', userId); + if (!userId) { + console.log('No userId provided'); return res.status(401).json({ message: 'Unauthorized' }); } - const user = await User.findOne({ id: userId }); + const user = await User.findOne({ clerkId: userId }); if (!user) { + console.log('User not found for clerkId:', userId); return res.status(404).json({ message: 'User not found' }); } if (req.method === 'GET') { + console.log('Returning user data:', user); res.json(user); } else if (req.method === 'PUT') { const { role } = req.body; + console.log('Updating user role to:', role); user.role = role; await user.save(); + console.log('User role updated successfully'); res.json(user); } else { + console.log('Method not allowed:', req.method); res.status(405).json({ message: 'Method not allowed' }); } }; \ No newline at end of file