Skip to content
Next Next commit
Fix lint
  • Loading branch information
BrunoQuaresma committed Sep 5, 2024
commit 219716db4a9dc48d04a1305bdb6cf18a4db80e13
22 changes: 17 additions & 5 deletions site/src/pages/UsersPage/UsersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ const UsersPage: FC = () => {
entity="user"
onCancel={() => setUserToDelete(undefined)}
onConfirm={async () => {
if (!userToDelete) {
return;
}
try {
await deleteUserMutation.mutateAsync(userToDelete!.id);
await deleteUserMutation.mutateAsync(userToDelete.id);
setUserToDelete(undefined);
displaySuccess("Successfully deleted the user.");
} catch (e) {
Expand All @@ -191,8 +194,11 @@ const UsersPage: FC = () => {
confirmText="Suspend"
onClose={() => setUserToSuspend(undefined)}
onConfirm={async () => {
if (!userToSuspend) {
return;
}
try {
await suspendUserMutation.mutateAsync(userToSuspend!.id);
await suspendUserMutation.mutateAsync(userToSuspend.id);
setUserToSuspend(undefined);
displaySuccess("Successfully suspended the user.");
} catch (e) {
Expand All @@ -216,8 +222,11 @@ const UsersPage: FC = () => {
confirmText="Activate"
onClose={() => setUserToActivate(undefined)}
onConfirm={async () => {
if (!userToActivate) {
return;
}
try {
await activateUserMutation.mutateAsync(userToActivate!.id);
await activateUserMutation.mutateAsync(userToActivate.id);
setUserToActivate(undefined);
displaySuccess("Successfully activated the user.");
} catch (e) {
Expand All @@ -242,10 +251,13 @@ const UsersPage: FC = () => {
setConfirmResetPassword(undefined);
}}
onConfirm={async () => {
if (!confirmResetPassword) {
return;
}
try {
await updatePasswordMutation.mutateAsync({
userId: confirmResetPassword!.user.id,
password: confirmResetPassword!.newPassword,
userId: confirmResetPassword.user.id,
password: confirmResetPassword.newPassword,
old_password: "",
});
setConfirmResetPassword(undefined);
Expand Down