mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-03 12:17:55 +00:00
fix: update user fields
This commit is contained in:
@ -46,10 +46,13 @@ const ChangePasswordDialog: React.FC<Props> = (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) {
|
||||
|
@ -97,16 +97,20 @@ const CreateUserDialog: React.FC<Props> = (props: Props) => {
|
||||
const userPatch: Partial<User> = {
|
||||
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);
|
||||
}
|
||||
|
@ -41,11 +41,14 @@ const EditUserinfoDialog: React.FC<Props> = (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) {
|
||||
|
Reference in New Issue
Block a user