add console logs

This commit is contained in:
Joseph J Helfenbein
2025-01-25 06:55:56 -05:00
parent a05321e8af
commit 67a5e145e0
2 changed files with 16 additions and 1 deletions

View File

@@ -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);
};

View File

@@ -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' });
}
};