Skip to content

Commit

Permalink
PR #1808 update & fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jng34 committed Nov 5, 2024
1 parent ee1f3f4 commit 1819aad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 3 additions & 1 deletion client/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const Navbar = (props) => {
{/* Admin auth -> Displays 2 links -> 'Users' and 'Projects'. */}
{auth?.user?.accessLevel === 'admin' && (
<>
{/* <StyledButton component={NavLink} to="/useradmin"> */}
{/* Testing UserPermissionSearch component from "/users/permission-search" route */}
{/* To be replaced with new Users component */}
<StyledButton component={NavLink} to="/users/permission-search">
{/*******************************************/}
USERS
</StyledButton>
<StyledButton component={NavLink} to="/projects">
Expand Down
3 changes: 1 addition & 2 deletions client/src/pages/UserAdmin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ const UserAdmin = () => {
}

if (Object.keys(userToEdit).length === 0) {
return <UserPermissionSearch users={users} setUserToEdit={setUserToEdit} />;
// return <UserManagement users={users} setUserToEdit={setUserToEdit} />;
return <UserManagement users={users} setUserToEdit={setUserToEdit} />;
} else {
return (
<EditUsers
Expand Down
21 changes: 10 additions & 11 deletions client/src/pages/UserPermissionSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ const dummyData = [
const DummyComponent = ({ data, type }) => {
return (
<List className="search-results disablePadding">
{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' ?
(
<ListItem
Expand All @@ -108,7 +107,7 @@ const DummyComponent = ({ data, type }) => {
borderBottom: 1.6,
borderBottomColor: 'grey.300',
}}
key={`result_${_id}/${idx}`}>
key={`result_${_id}/${index}`}>
<ListItemButton
sx={{
px: 0.25,
Expand All @@ -118,7 +117,7 @@ const DummyComponent = ({ data, type }) => {
}}
className="search-results-button"
type="button"
onClick={() => setUserToEdit(u)}
onClick={() => setUserToEdit(user)}
>
<Grid container>
<Grid item>
Expand All @@ -138,7 +137,7 @@ const DummyComponent = ({ data, type }) => {
borderBottom: 1.6,
borderBottomColor: 'grey.300',
}}
key={`result_${_id}/${idx}`}>
key={`result_${_id}/${index}`}>
<ListItemButton
sx={{
px: 0.25,
Expand All @@ -148,14 +147,14 @@ const DummyComponent = ({ data, type }) => {
}}
className="search-results-button"
type="button"
onClick={() => setUserToEdit(u)}
onClick={() => setUserToEdit(user)}
>
<Grid container justifyContent={"space-between"}>
<Grid item>
<Typography style={{fontWeight: 600}}>{name.firstName.toUpperCase() + " " + name.lastName.toUpperCase()}</Typography>
</Grid>
<Grid item>
<Typography style={{fontWeight: 600}} color='black'>{u.project}</Typography>
<Typography style={{fontWeight: 600}} color='black'>{user.project}</Typography>
</Grid>
</Grid>
</ListItemButton>
Expand All @@ -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';
Expand Down

0 comments on commit 1819aad

Please sign in to comment.