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
d56280a9
Commit
d56280a9
authored
Nov 05, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#10
Утвердился, что все работает
parent
b0374cba
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
7 deletions
+5
-7
App.js
planner-front/src/App.js
+4
-3
Login.js
planner-front/src/containers/Login/Login.js
+0
-1
usersActions.js
planner-front/src/store/actions/usersActions.js
+0
-2
usersReducer.js
planner-front/src/store/reducers/usersReducer.js
+1
-1
No files found.
planner-front/src/App.js
View file @
d56280a9
import
{
Routes
,
Route
,
Outlet
,
Navigate
,
BrowserRouter
}
from
"react-router-dom"
;
import
{
Container
}
from
"@mui/material"
;
import
{
useSelector
}
from
"react-redux"
;
import
AppToolbar
from
"./components/UI/AppToolBar/AppToolBar"
;
import
AppToolbar
from
'./components/UI/AppToolBar/AppToolbar'
import
MyTasks
from
'./containers/MyTasks/MyTasks'
import
Login
from
'./containers/Login/Login'
import
Register
from
'./containers/Register/Register'
const
ProtectedRoute
=
({
isAllowed
,
roles
,
redirectUrl
,
children
})
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
console
.
log
(
user
)
if
(
!
isAllowed
&&
!
roles
?.
includes
(
user
?.
role
))
{
return
<
Navigate
to
=
{
redirectUrl
}
/
>
}
...
...
@@ -14,7 +16,6 @@ const ProtectedRoute = ({isAllowed, roles, redirectUrl, children}) => {
const
App
=
()
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
console
.
log
(
user
)
return
(
<
BrowserRouter
>
<
Routes
>
...
...
planner-front/src/containers/Login/Login.js
View file @
d56280a9
...
...
@@ -30,7 +30,6 @@ const Login = () => {
const
dispatch
=
useDispatch
();
const
{
loginError
,
loading
}
=
useSelector
(
state
=>
state
.
users
);
console
.
log
(
loginError
)
const
navigate
=
useNavigate
(
"/"
)
const
inputChangeHandler
=
(
e
)
=>
{
...
...
planner-front/src/store/actions/usersActions.js
View file @
d56280a9
...
...
@@ -20,7 +20,6 @@ export const registerUser = (userData, navigate) => {
try
{
const
response
=
await
axios
.
post
(
"/users"
,
userData
);
dispatch
(
registerUserSuccess
())
console
.
log
(
response
)
navigate
(
"/"
)
}
catch
(
error
)
{
if
(
error
.
response
?.
data
)
{
...
...
@@ -54,7 +53,6 @@ export const loginUser = (userData, navigate) => {
dispatch
(
loginUserSuccess
(
response
.
data
));
navigate
(
"/"
)
}
catch
(
e
)
{
console
.
dir
(
e
)
dispatch
(
loginUserFailure
(
e
?.
response
?.
data
?.
err
))
}
}
...
...
planner-front/src/store/reducers/usersReducer.js
View file @
d56280a9
...
...
@@ -5,7 +5,7 @@ const initialState = {
name
:
'Ivan'
,
surname
:
'Petrov'
,
email
:
'test@gmail.com'
,
role
:
'
super
user'
role
:
'user'
},
registerError
:
null
,
loginError
:
null
,
...
...
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