Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit d881df5

Browse files
Update delete user to deactivate user instead
1 parent 75b28c6 commit d881df5

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

src/components/EditProfileModal/index.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export default function EditProfileModal({
1515
onCancel,
1616
updateUser,
1717
user,
18-
deleteUser,
18+
deactivateUser,
1919
}) {
2020
const [localUser, setLocalUser] = React.useState(user);
2121
const [isSavingChanges, setIsSavingChanges] = React.useState(false);
22-
const [isDeletingUser, setIsDeletingUser] = React.useState(false);
22+
const [isDeactivatingUser, setisDeactivatingUser] = React.useState(false);
2323

2424
const updateUserFromChild = (userDataFromChild) => {
2525
// Only availability can be updated
@@ -33,10 +33,10 @@ export default function EditProfileModal({
3333
});
3434
};
3535

36-
const confirmDeleteUser = () => {
37-
if (window.confirm("Are you sure you want to delete this user?")) {
38-
setIsDeletingUser(true);
39-
deleteUser();
36+
const confirmDeactivateUser = () => {
37+
if (window.confirm("Are you sure you want to deactivate this user?")) {
38+
setisDeactivatingUser(true);
39+
deactivateUser();
4040
}
4141
};
4242

@@ -97,7 +97,7 @@ export default function EditProfileModal({
9797
<h1>Edit Profile</h1>
9898
<Button
9999
onClick={onCancel}
100-
disabled={isSavingChanges || isDeletingUser}
100+
disabled={isSavingChanges || isDeactivatingUser}
101101
>
102102
Cancel
103103
</Button>
@@ -109,7 +109,7 @@ export default function EditProfileModal({
109109
setIsSavingChanges(true);
110110
updateUser(localUser);
111111
}}
112-
disabled={isSavingChanges || isDeletingUser}
112+
disabled={isSavingChanges || isDeactivatingUser}
113113
>
114114
{isSavingChanges ? "Saving changes, please wait..." : "Save"}
115115
</Button>
@@ -233,12 +233,12 @@ export default function EditProfileModal({
233233
</div>
234234
<Button
235235
className={
236-
isDeletingUser ? style.disabledDangerButton : style.dangerButton
236+
isDeactivatingUser ? style.disabledDangerButton : style.dangerButton
237237
}
238-
onClick={confirmDeleteUser}
239-
disabled={isDeletingUser || isSavingChanges}
238+
onClick={confirmDeactivateUser}
239+
disabled={isDeactivatingUser || isSavingChanges}
240240
>
241-
{isDeletingUser ? "Deleting" : "Delete this user"}
241+
{isDeactivatingUser ? "Deactivating" : "Deactivate this user"}
242242
</Button>
243243
</div>
244244
</Modal>
@@ -248,6 +248,6 @@ export default function EditProfileModal({
248248
EditProfileModal.propTypes = {
249249
onCancel: PT.func.isRequired,
250250
updateUser: PT.func.isRequired,
251-
deleteUser: PT.func.isRequired,
251+
deactivateUser: PT.func.isRequired,
252252
user: PT.shape().isRequired,
253253
};

src/components/ProfileCard/index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import config from "../../config";
1111
import * as groupLib from "../../lib/groups";
1212
import api from "../../services/api";
1313
import * as cardHelper from "./helper";
14+
import { getSingleOrg } from "../../services/user-org";
1415

1516
import styles from "./profileCard.module.css";
1617
import iconStyles from "../../styles/icons.module.css";
@@ -55,9 +56,9 @@ function ProfileCard({
5556
),
5657
companyAttributes: cardHelper.getUserCompanyAttributeDetails(profile),
5758
avatarColor,
58-
// Indicates if the user has been deleted. The user is still shown in this case, but with a
59-
// clear indicator about its deleted status.
60-
isDeleted: false,
59+
// Indicates if the user has been deactivated. The user is still shown in this case, but with a
60+
// clear indicator about its deactivated status.
61+
isDeactivated: false,
6162
};
6263
} else {
6364
// Data is already in the format seen above. No further processing needed
@@ -194,22 +195,23 @@ function ProfileCard({
194195
};
195196

196197
/**
197-
* Deletes the user
198+
* Deactivates the user
198199
* ! Will call api to update value in database
199200
*/
200-
const deleteUser = async () => {
201-
const url = `${config.API_URL}/users/${user.id}`;
201+
const deactivateUser = async () => {
202+
const organizationId = getSingleOrg();
203+
const url = `${config.API_URL}/users/${user.id}/externalProfiles/${organizationId}`;
202204

203205
try {
204-
await apiClient.delete(url);
206+
await apiClient.patch(url, { isInactive: true });
205207
} catch (error) {
206208
console.log(error);
207209
// TODO - Handle error
208210
return;
209211
}
210212

211213
setShowEditUserModal(false);
212-
setUser({ ...user, isDeleted: true });
214+
setUser({ ...user, isDeactivated: true });
213215
};
214216

215217
/**
@@ -269,7 +271,7 @@ function ProfileCard({
269271
onCancel={() => setShowEditUserModal(false)}
270272
updateUser={updateUserFromChild}
271273
user={user}
272-
deleteUser={deleteUser}
274+
deactivateUser={deactivateUser}
273275
/>
274276
) : null}
275277
<div className={styles.profileCardHeaderContainer}>
@@ -329,9 +331,9 @@ function ProfileCard({
329331
/>
330332
</div>
331333
</div>
332-
{user.isDeleted && (
333-
<div className={styles.deletedCard}>
334-
<span>This user has been deleted</span>
334+
{user.isDeactivated && (
335+
<div className={styles.deactivatedCard}>
336+
<span>This user has been deactivated</span>
335337
</div>
336338
)}
337339
</div>

src/components/ProfileCard/profileCard.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
display: none;
3838
}
3939

40-
.deletedCard {
40+
.deactivatedCard {
4141
position: absolute;
4242
top: 0;
4343
left: 0;
@@ -51,7 +51,7 @@
5151
align-items: center;
5252
}
5353

54-
.deletedCard span {
54+
.deactivatedCard span {
5555
display: table-cell;
5656
vertical-align: middle;
5757
font-family: Helvetica;

0 commit comments

Comments
 (0)