#74 switch user current projects display fix

parent d6073f38
...@@ -30,7 +30,6 @@ const ProfileBlock = () => { ...@@ -30,7 +30,6 @@ const ProfileBlock = () => {
} }
const switchUser=()=>{ const switchUser=()=>{
dispatch(fetchUsersAllFields()); dispatch(fetchUsersAllFields());
// dispatch(fetchUsers())
handleClose() handleClose()
handleOpenSwitchUser() handleOpenSwitchUser()
} }
......
...@@ -13,24 +13,24 @@ const SwitchUserForm=({submitFormHandler, users})=> { ...@@ -13,24 +13,24 @@ const SwitchUserForm=({submitFormHandler, users})=> {
setCurrentUser(user) setCurrentUser(user)
setProjectsRole([]) setProjectsRole([])
} }
console.log('projectsRoles ', projectsRoles)
useEffect(()=>{ useEffect(()=>{
if(currentUser?.members.length>0) { if(currentUser?.members.length>0) {
let dataArray=[]
for (let member of currentUser.members ) { for (let member of currentUser.members ) {
let newProjectRole = { const newProjectRole = {
"projectName":member.project.title, "projectName":member.project.title,
"roleName":member.roleProject "roleName":member.roleProject
} }
setProjectsRole([...projectsRoles, newProjectRole ]) dataArray.push(newProjectRole)
} }
setProjectsRole(dataArray)
} }
},[ currentUser]) },[ currentUser])
return ( return (
<> <>
{/* <Box sx={style}> */}
{users? {users?
<form onSubmit={(e)=>submitFormHandler(e,currentUser)}> <form onSubmit={(e)=>submitFormHandler(e,currentUser)}>
<Grid container direction="column" spacing={2}> <Grid container direction="column" spacing={2}>
...@@ -67,15 +67,7 @@ const SwitchUserForm=({submitFormHandler, users})=> { ...@@ -67,15 +67,7 @@ const SwitchUserForm=({submitFormHandler, users})=> {
</Button> </Button>
</Grid> </Grid>
{/* <Grid item>
<Button
onClick={()=>console.log('cancel form')}
color="primary"
variant="contained"
>
Отмена
</Button>
</Grid> */}
</Grid> </Grid>
</Grid> </Grid>
...@@ -83,7 +75,6 @@ const SwitchUserForm=({submitFormHandler, users})=> { ...@@ -83,7 +75,6 @@ const SwitchUserForm=({submitFormHandler, users})=> {
: <></>} : <></>}
{/* </Box> */}
</> </>
) )
} }
......
...@@ -9,7 +9,6 @@ import Paper from '@mui/material/Paper'; ...@@ -9,7 +9,6 @@ import Paper from '@mui/material/Paper';
const SwitchUserTable=({projectsRoles})=>{ const SwitchUserTable=({projectsRoles})=>{
return ( return (
<TableContainer component={Paper}> <TableContainer component={Paper}>
...@@ -31,7 +30,8 @@ const SwitchUserTable=({projectsRoles})=>{ ...@@ -31,7 +30,8 @@ const SwitchUserTable=({projectsRoles})=>{
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{projectsRoles.map((projectRole,index) => ( {projectsRoles.map((projectRole,index) =>{ return (
<TableRow <TableRow
key={index} key={index}
sx={{ '&:last-child td, &:last-child th': { border: 0 } }} sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
...@@ -41,7 +41,7 @@ const SwitchUserTable=({projectsRoles})=>{ ...@@ -41,7 +41,7 @@ const SwitchUserTable=({projectsRoles})=>{
</TableCell> </TableCell>
<TableCell align="right">{projectRole.roleName}</TableCell> <TableCell align="right">{projectRole.roleName}</TableCell>
</TableRow> </TableRow>
))} )})}
</TableBody> </TableBody>
</Table> </Table>
</TableContainer> </TableContainer>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment