Skip to content

Commit

Permalink
Added api route handler for update-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Jun 15, 2024
1 parent 9dd4d38 commit 27a2a42
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/api/patient/update-profile/profile/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import dbConfig from "@lib/db";
import { decrypt } from "@sessions/sessionUtils";

export async function PUT(request: Request) {
// const session = request.headers.get("Authorization");
// if (!session) {
// return Response.json({ error: "Unauthorized" }, { status: 401 });
// }

const profile_pic = await request.json();

try {
// const token = session.split("Bearer ")[1];
// const decryptedUser = await decrypt(token);
const patient_email = "[email protected]"; //decryptedUser.user.email;

const db = await dbConfig();
const collection = db.collection("patient");

const result = await collection.updateOne(
{ email: patient_email },
{ $set: { profile: profile_pic } }
);

if (!result) {
return Response.json({ error: "Error updating profile picture" });
}

return Response.json({ msg: "ok" });
} catch (error) {
console.error("Error updating patient profile picture :", error);
return Response.json({ error: "Internal Server Error" }, { status: 500 });
}
}

0 comments on commit 27a2a42

Please sign in to comment.