Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
planner-team-one
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
21
Issues
21
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Евгений Положенцев
planner-team-one
Commits
b2d180f0
Commit
b2d180f0
authored
Dec 10, 2022
by
Евгений Положенцев
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#94
added modal windowSwithcUser
parent
0b900d0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
2 deletions
+60
-2
ProfileBlock.js
...r-front/src/components/Menus/ProfileBlock/ProfileBlock.js
+19
-2
SwitchUserModal.js
...r-front/src/components/SwitchUserModal/SwitchUserModal.js
+41
-0
No files found.
planner-front/src/components/Menus/ProfileBlock/ProfileBlock.js
View file @
b2d180f0
...
...
@@ -2,7 +2,8 @@ import {Button, Menu, MenuItem} from "@mui/material";
import
{
useState
}
from
"react"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
NavLink
,
useNavigate
}
from
"react-router-dom"
;
import
{
logoutUser
}
from
"../../../store/actions/usersActions"
;
import
{
fetchUsersAllFields
,
logoutUser
}
from
"../../../store/actions/usersActions"
;
import
SwitchUserModal
from
"../../SwitchUserModal/SwitchUserModal"
;
const
ProfileBlock
=
()
=>
{
const
dispatch
=
useDispatch
();
...
...
@@ -10,6 +11,10 @@ const ProfileBlock = () => {
const
[
anchorEl
,
setAnchorEl
]
=
useState
(
null
);
const
open
=
Boolean
(
anchorEl
);
const
user
=
useSelector
(
state
=>
state
.
users
.
user
)
const
[
openSwitchUser
,
setOpenSwitchUser
]
=
useState
(
false
);
const
handleCloseSwitchUser
=
()
=>
setOpenSwitchUser
(
false
);
const
handleClick
=
(
event
)
=>
{
setAnchorEl
(
event
.
currentTarget
);
...
...
@@ -18,10 +23,18 @@ const ProfileBlock = () => {
setAnchorEl
(
null
);
};
const
handleOpenSwitchUser
=
()
=>
setOpenSwitchUser
(
true
);
const
logout
=
()
=>
{
dispatch
(
logoutUser
(
navigate
));
handleClose
()
}
const
switchUser
=
()
=>
{
dispatch
(
fetchUsersAllFields
());
handleClose
()
handleOpenSwitchUser
()
}
return
<>
<
Button
color
=
"inherit"
...
...
@@ -37,9 +50,13 @@ const ProfileBlock = () => {
>
<
MenuItem
component
=
{
NavLink
}
to
=
"/profile/test"
color
=
"inherit"
onClick
=
{
handleClose
}
>
Profile
<
/MenuItem
>
<
MenuItem
onClick
=
{()
=>
{
logout
()}}
>
Поменять
юзера
<
/MenuItem
>
<
MenuItem
onClick
=
{()
=>
{
switchUser
()}}
>
Поменять
юзера
<
/MenuItem
>
<
MenuItem
onClick
=
{()
=>
{
logout
()}}
>
Logout
<
/MenuItem
>
<
/Menu
>
<
SwitchUserModal
open
=
{
openSwitchUser
}
handleClose
=
{
handleCloseSwitchUser
}
/
>
<
/
>
};
...
...
planner-front/src/components/SwitchUserModal/SwitchUserModal.js
0 → 100644
View file @
b2d180f0
import
*
as
React
from
'react'
;
import
Box
from
'@mui/material/Box'
;
import
Button
from
'@mui/material/Button'
;
import
Typography
from
'@mui/material/Typography'
;
import
Modal
from
'@mui/material/Modal'
;
const
style
=
{
position
:
'absolute'
,
top
:
'50%'
,
left
:
'50%'
,
transform
:
'translate(-50%, -50%)'
,
width
:
400
,
bgcolor
:
'background.paper'
,
border
:
'2px solid #000'
,
boxShadow
:
24
,
p
:
4
,
};
const
SwitchUserModal
=
({
open
,
handleClose
})
=>
{
return
(
<
div
>
<
Modal
open
=
{
open
}
onClose
=
{
handleClose
}
aria
-
labelledby
=
"modal-modal-title"
aria
-
describedby
=
"modal-modal-description"
>
<
Box
sx
=
{
style
}
>
<
Typography
id
=
"modal-modal-title"
variant
=
"h6"
component
=
"h2"
>
Text
in
a
modal
<
/Typography
>
<
Typography
id
=
"modal-modal-description"
sx
=
{{
mt
:
2
}}
>
Duis
mollis
,
est
non
commodo
luctus
,
nisi
erat
porttitor
ligula
.
<
/Typography
>
<
/Box
>
<
/Modal
>
<
/div
>
);
}
export
default
SwitchUserModal
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment