From 898b2b6f506fa51bf29e726c8317298e71456e1c Mon Sep 17 00:00:00 2001 From: celesca Date: Fri, 8 Nov 2024 00:15:00 +0700 Subject: [PATCH] fix: userController --- src/controllers/userController.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/controllers/userController.ts b/src/controllers/userController.ts index 7a9b48c..3305ef2 100644 --- a/src/controllers/userController.ts +++ b/src/controllers/userController.ts @@ -83,7 +83,7 @@ export const userController = new Elysia({ prefix: "/user" }) .put( "/:userID", async ({ params: { userID }, body, error }) => { - const { userName } = body; + const { userName, email, password, workingStyle, profileImage, bio } = body; // Check if the user exists const user = await prisma.user.findUnique({ @@ -99,6 +99,11 @@ export const userController = new Elysia({ prefix: "/user" }) where: { UserID: userID }, data: { UserName: userName, + Email: email, + Password: password, + WorkingStyle: workingStyle, + ProfileImage: profileImage, + Bio: bio, }, }); @@ -109,9 +114,14 @@ export const userController = new Elysia({ prefix: "/user" }) userID: t.String(), }), body: t.Object({ - userName: t.String(), - }), - } + userName: t.Optional(t.String()), + email: t.Optional(t.String()), + password: t.Optional(t.String()), + workingStyle: t.Optional(t.String()), + profileImage: t.Optional(t.String()), + bio: t.Optional(t.String()), + }), + } ) // Delete user profile