Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 59 additions & 23 deletions client/src/components/user-admin/EditUsers.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,65 @@
import { useEffect, useState } from 'react';
import {
Grid,
FormGroup,
FormControlLabel,
Switch,
Button,
Typography,
Container,
FormControl,
FormControlLabel,
FormGroup,
Grid,
InputLabel,
List,
ListItem,
ListItemText,
Select,
MenuItem,
FormControl,
InputLabel,
Select,
Switch,
Typography,
} from '@mui/material';
import { useEffect, useState } from 'react';
import '../../sass/UserAdmin.scss';
import useAuth from '../../hooks/useAuth';
import { ROLES } from '../../../../shared/roles';
import useAuth from '../../hooks/useAuth';

const muiSwitchStyles = {
width: 40,
height: 24,
padding: 0,
top: 4,
marginRight: 2,
marginLeft: 1,
'& .MuiSwitch-switchBase': {
padding: 0,
margin: '4px',
color: '#6b7280',
'&.Mui-checked': {
transform: 'translateX(16px)',
color: '#fff',
},
'&.Mui-checked + .MuiSwitch-track': {
backgroundColor: '#359F3A',
borderColor: '#359F3A',
opacity: 1,
},
},
'& .MuiSwitch-thumb': {
width: 8,
height: 8,
boxShadow: 'none',
},
'& .MuiSwitch-track': {
width: 32,
height: 16,
borderRadius: 1000,
backgroundColor: '#fff',
border: '2px solid #6b7280',
opacity: 1,
boxSizing: 'border-box',
},
};

const muiFormControlLabelStyles = {
alignItems: 'flex-end',
marginLeft: 1,
};

// child of UserAdmin. Displays form to update users.
const EditUsers = ({
Expand Down Expand Up @@ -51,9 +93,7 @@ const EditUsers = ({
setUserManagedProjects(userToEdit.managedProjects);
}, [userToEdit]);

const userProjectsToDisplay = activeProjects.filter((item) =>
userProjects.includes(item[0]),
);
const userProjectsToDisplay = activeProjects.filter((item) => userProjects.includes(item[0]));

const onSubmit = (event) => {
event.preventDefault();
Expand All @@ -75,9 +115,7 @@ const EditUsers = ({

const handleRemoveProject = (projectToRemove) => {
if (!superAdmin && userManagedProjects.length > 0) {
const newProjects = userManagedProjects.filter(
(p) => p !== projectToRemove,
);
const newProjects = userManagedProjects.filter((p) => p !== projectToRemove);
updateUserDb(userToEdit, projectToRemove, 'remove');
setUserManagedProjects(newProjects);
}
Expand Down Expand Up @@ -107,10 +145,11 @@ const EditUsers = ({
Is Active:
</Typography>
<FormControlLabel
sx={{ marginLeft: 1 }}
sx={muiFormControlLabelStyles}
control={
<Switch
checked={isActive}
sx={muiSwitchStyles}
onChange={handleSetIsActive}
disabled={superAdmin}
/>
Expand All @@ -123,10 +162,11 @@ const EditUsers = ({
VRMS Admin:
</Typography>
<FormControlLabel
sx={{ marginLeft: 1 }}
sx={muiFormControlLabelStyles}
control={
<Switch
checked={admin || superAdmin}
sx={muiSwitchStyles}
onChange={handleSetAccessLevel}
disabled={superAdmin}
/>
Expand Down Expand Up @@ -183,11 +223,7 @@ const EditUsers = ({
Add project
</Button>
</FormControl>
<Button
variant="outlined"
onClick={backToSearch}
style={{ marginTop: '1rem' }}
>
<Button variant="outlined" onClick={backToSearch} style={{ marginTop: '1rem' }}>
Back to search
</Button>
</Container>
Expand Down
Loading