diff --git a/frontend/web/src/components/ChangePasswordDialog.tsx b/frontend/web/src/components/ChangePasswordDialog.tsx index 94d8074..fbb5ab0 100644 --- a/frontend/web/src/components/ChangePasswordDialog.tsx +++ b/frontend/web/src/components/ChangePasswordDialog.tsx @@ -46,10 +46,13 @@ const ChangePasswordDialog: React.FC = (props: Props) => { requestState.setLoading(); try { - userStore.patchUser({ - id: userStore.getCurrentUser().id, - password: newPassword, - }); + userStore.patchUser( + { + id: userStore.getCurrentUser().id, + password: newPassword, + }, + ["password"], + ); onClose(); toast("Password changed"); } catch (error: any) { diff --git a/frontend/web/src/components/CreateUserDialog.tsx b/frontend/web/src/components/CreateUserDialog.tsx index 20ea945..20927ea 100644 --- a/frontend/web/src/components/CreateUserDialog.tsx +++ b/frontend/web/src/components/CreateUserDialog.tsx @@ -97,16 +97,20 @@ const CreateUserDialog: React.FC = (props: Props) => { const userPatch: Partial = { id: user.id, }; + const updateMask: string[] = []; if (user.email !== state.userCreate.email) { userPatch.email = state.userCreate.email; + updateMask.push("email"); } if (user.nickname !== state.userCreate.nickname) { userPatch.nickname = state.userCreate.nickname; + updateMask.push("nickname"); } if (user.role !== state.userCreate.role) { userPatch.role = state.userCreate.role; + updateMask.push("role"); } - await userStore.patchUser(userPatch); + await userStore.patchUser(userPatch, updateMask); } else { await userStore.createUser(state.userCreate); } diff --git a/frontend/web/src/components/EditUserinfoDialog.tsx b/frontend/web/src/components/EditUserinfoDialog.tsx index 7d81a83..f855d6e 100644 --- a/frontend/web/src/components/EditUserinfoDialog.tsx +++ b/frontend/web/src/components/EditUserinfoDialog.tsx @@ -41,11 +41,14 @@ const EditUserinfoDialog: React.FC = (props: Props) => { requestState.setLoading(); try { - await userStore.patchUser({ - id: currentUser.id, - email, - nickname, - }); + await userStore.patchUser( + { + id: currentUser.id, + email, + nickname, + }, + ["email", "nickname"], + ); onClose(); toast("User information updated"); } catch (error: any) { diff --git a/frontend/web/src/stores/user.ts b/frontend/web/src/stores/user.ts index 1eee65b..063506d 100644 --- a/frontend/web/src/stores/user.ts +++ b/frontend/web/src/stores/user.ts @@ -16,7 +16,7 @@ interface UserState { getCurrentUser: () => User; setCurrentUserId: (id: number) => void; createUser: (create: Partial) => Promise; - patchUser: (userPatch: Partial) => Promise; + patchUser: (userPatch: Partial, updateMask: string[]) => Promise; deleteUser: (id: number) => Promise; // User setting related actions. @@ -75,10 +75,10 @@ const useUserStore = create()((set, get) => ({ set(userMap); return user; }, - patchUser: async (userPatch: Partial) => { + patchUser: async (userPatch: Partial, updateMask: string[]) => { const { user } = await userServiceClient.updateUser({ user: userPatch, - updateMask: ["email", "nickname"], + updateMask: updateMask, }); if (!user) { throw new Error("User not found");