Skip to content

Commit 69d9ac4

Browse files
jng34trillium
authored andcommitted
fix bugs preventing proper updating of user profile during search nav
1 parent 28ed1d1 commit 69d9ac4

4 files changed

Lines changed: 14 additions & 15 deletions

File tree

client/src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const routes = [
6565
{
6666
path: '/users/permission-search',
6767
name: 'useradmin',
68-
Component: UserPermission,
68+
Component: withAuth(UserPermission),
6969
},
7070
{
7171
path: '/projects/visibility',

client/src/components/user-admin/EditUsers.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import '../../sass/UserAdmin.scss';
1919
import useAuth from '../../hooks/useAuth';
2020

21-
21+
// child of UserAdmin. Displays form to update users.
2222
const EditUsers = ({
2323
userToEdit,
2424
backToSearch,
@@ -80,7 +80,7 @@ const EditUsers = ({
8080
setUserManagedProjects(newProjects);
8181
}
8282
};
83-
83+
8484
const handleSetIsActive = () => {
8585
if (!isSuperAdmin) {
8686
setIsActive(!isActive);

client/src/components/user-admin/UserPermissionSearch.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ const Buttonsx = {
2020
py: 0.5,
2121
};
2222

23-
const DummyComponent = ({ data, isProjectLead, setUserToEdit }) => {
24-
const { auth } = useAuth();
23+
const ListComponent = ({ data, isProjectLead, setUserToEdit }) => {
2524
return (
2625
<List className="search-results disablePadding">
2726
{data.map((u, idx) => {
@@ -104,12 +103,12 @@ const DummyComponent = ({ data, isProjectLead, setUserToEdit }) => {
104103
);
105104
};
106105

107-
const UserPermissionSearch = ({ admins, projectLeads, setUserToEdit }) => {
106+
const UserPermissionSearch = ({ admins, projectManagers, setUserToEdit }) => {
108107
const { searchText, setSearchText, userType, setUserType, isProjectLead, setIsProjectLead } = useSearchText(); // React context hook
109108

110109
const location = useLocation();
111110

112-
const resultData = [...admins, ...projectLeads];
111+
const resultData = [...admins, ...projectManagers];
113112

114113
useEffect(() => {
115114
// Edit url by adding '/admin' upon loading
@@ -328,7 +327,7 @@ const UserPermissionSearch = ({ admins, projectLeads, setUserToEdit }) => {
328327
>
329328
<Box>
330329
{/*Component to render admins and PMs*/}
331-
<DummyComponent
330+
<ListComponent
332331
data={filteredData}
333332
isProjectLead={isProjectLead}
334333
setUserToEdit={setUserToEdit}

client/src/pages/UserPermission.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ const UserPermission = () => {
2929
}, [userApiService]);
3030

3131
const updateUserDb = useCallback(
32-
async (user, managedProjects) => {
33-
await userApiService.updateUserDbProjects(user, managedProjects);
32+
async (user, managedProjects, action) => {
33+
await userApiService.updateUserDbProjects(user, managedProjects, action);
3434
fetchAdmins();
3535
},
3636
[userApiService, fetchAdmins]
3737
);
3838

3939
const updateUserActiveStatus = useCallback(
4040
async (user, isActive) => {
41-
await userApiService.updateUserDbIsActive(admins, isActive);
41+
await userApiService.updateUserDbIsActive(user, isActive);
4242
fetchAdmins();
4343
},
4444
[userApiService, fetchAdmins]
4545
);
4646

4747
// Update user's access level (admin/user)
4848
const updateUserAccessLevel = useCallback(
49-
async (admin, newAccessLevel) => {
50-
await userApiService.updateUserAccessLevel(admin, newAccessLevel);
49+
async (user, newAccessLevel) => {
50+
await userApiService.updateUserAccessLevel(user, newAccessLevel);
5151
fetchAdmins();
5252
},
5353
[userApiService, fetchAdmins]
@@ -62,7 +62,7 @@ const UserPermission = () => {
6262
fetchAdmins();
6363
fetchProjects();
6464
fetchProjectsManagers();
65-
}, [fetchAdmins, fetchProjects, fetchProjectsManagers]);
65+
}, [userToEdit, fetchAdmins, fetchProjects, fetchProjectsManagers]);
6666

6767
const backToSearch = () => {
6868
setUserToEdit({});
@@ -76,7 +76,7 @@ const UserPermission = () => {
7676
return (
7777
<UserPermissionSearch
7878
admins={admins}
79-
projectLeads={projectManagers}
79+
projectManagers={projectManagers}
8080
setUserToEdit={setUserToEdit}
8181
/>
8282
);

0 commit comments

Comments
 (0)