From 1819aadfecd594d44cbe880a94e86c02c34703d9 Mon Sep 17 00:00:00 2001 From: JamesNg Date: Mon, 4 Nov 2024 23:45:29 -0500 Subject: [PATCH] PR #1808 update & fixes --- client/src/components/Navbar.jsx | 4 +++- client/src/pages/UserAdmin.jsx | 3 +-- client/src/pages/UserPermissionSearch.jsx | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/src/components/Navbar.jsx b/client/src/components/Navbar.jsx index 0cfdc5b0..5ed26624 100644 --- a/client/src/components/Navbar.jsx +++ b/client/src/components/Navbar.jsx @@ -61,8 +61,10 @@ const Navbar = (props) => { {/* Admin auth -> Displays 2 links -> 'Users' and 'Projects'. */} {auth?.user?.accessLevel === 'admin' && ( <> - {/* */} + {/* Testing UserPermissionSearch component from "/users/permission-search" route */} + {/* To be replaced with new Users component */} + {/*******************************************/} USERS diff --git a/client/src/pages/UserAdmin.jsx b/client/src/pages/UserAdmin.jsx index b07eea06..359554f7 100644 --- a/client/src/pages/UserAdmin.jsx +++ b/client/src/pages/UserAdmin.jsx @@ -66,8 +66,7 @@ const UserAdmin = () => { } if (Object.keys(userToEdit).length === 0) { - return ; - // return ; + return ; } else { return ( { return ( - {data.map((u, idx) => { + {data.map((user, index) => { // Destructure user object - const { _id, name, email } = u; - // return projects.length === 0 ? + const { _id, name, email } = user; return type === 'admin' ? ( { borderBottom: 1.6, borderBottomColor: 'grey.300', }} - key={`result_${_id}/${idx}`}> + key={`result_${_id}/${index}`}> { }} className="search-results-button" type="button" - onClick={() => setUserToEdit(u)} + onClick={() => setUserToEdit(user)} > @@ -138,7 +137,7 @@ const DummyComponent = ({ data, type }) => { borderBottom: 1.6, borderBottomColor: 'grey.300', }} - key={`result_${_id}/${idx}`}> + key={`result_${_id}/${index}`}> { }} className="search-results-button" type="button" - onClick={() => setUserToEdit(u)} + onClick={() => setUserToEdit(user)} > {name.firstName.toUpperCase() + " " + name.lastName.toUpperCase()} - {u.project} + {user.project} @@ -168,13 +167,13 @@ const DummyComponent = ({ data, type }) => { const UserPermissionSearch = ({ users, setUserToEdit }) => { - const [userType, setUserType] = useState('admin'); // Which results will diplay - const [searchText, setSearchText] = useState(''); // Serch term for the admin/PM search + const [userType, setUserType] = useState('admin'); // Which results will display + const [searchText, setSearchText] = useState(''); // Search term for the admin/PM search const location = useLocation(); useEffect(() => { - // Edit url by adding '/admin' upon loading + // Edits url by adding '/admin' upon loading let editURL = ''; if (userType === 'admin') { editURL = location.pathname + '/admin';