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
7a7a2f14
Commit
7a7a2f14
authored
Nov 02, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#13
Реализовал разные доступы к ссылкам
parent
6fc542a3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
7 deletions
+72
-7
App.js
planner-front/src/App.js
+72
-7
No files found.
planner-front/src/App.js
View file @
7a7a2f14
...
...
@@ -3,8 +3,16 @@ import {Container} from "@mui/material";
import
{
useSelector
}
from
"react-redux"
;
import
AppToolbar
from
"./components/UI/AppToolBar/AppToolBar"
;
const
ProtectedRoute
=
({
isAllowed
,
roles
,
redirectUrl
,
children
})
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
if
(
!
isAllowed
&&
!
roles
?.
includes
(
user
?.
role
))
{
return
<
Navigate
to
=
{
redirectUrl
}
/
>
}
return
children
||
<
Outlet
/>
;
};
const
App
=
()
=>
{
const
user
=
useSelector
(
state
=>
state
.
users
?.
user
);
return
(
<
BrowserRouter
>
<
Routes
>
...
...
@@ -18,13 +26,70 @@ const App = () => {
<
/main
>
<
/
>
}
>
<
Route
path
=
{
"/"
}
element
=
{
<
h1
>
week
page
<
/h1>}/
>
<
Route
path
=
{
"/week"
}
element
=
{
<
h1
>
week
page
<
/h1>}/
>
<
Route
path
=
{
"/month"
}
element
=
{
<
h1
>
month
page
<
/h1>}/
>
<
Route
path
=
{
"/my-tasks"
}
element
=
{
<
h1
>
my
tasks
page
<
/h1>}/
>
<
Route
path
=
{
"/workers-tasks"
}
element
=
{
<
h1
>
workers
tasks
page
<
/h1>}/
>
<
Route
path
=
{
"/profile/:id"
}
element
=
{
<
h1
>
profile
page
<
/h1>}/
>
<
Route
path
=
{
"/sign-up"
}
element
=
{
<
h1
>
sign
-
up
page
<
/h1>}/
>
<
Route
path
=
{
"/"
}
element
=
{
<
ProtectedRoute
isAllowed
=
{
user
}
redirectUrl
=
{
"/log-in"
}
>
<
h1
>
week
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/week"
}
element
=
{
<
ProtectedRoute
isAllowed
=
{
user
}
redirectUrl
=
{
"/log-in"
}
>
<
h1
>
week
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/month"
}
element
=
{
<
ProtectedRoute
isAllowed
=
{
user
}
redirectUrl
=
{
"/log-in"
}
>
<
h1
>
month
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/my-tasks"
}
element
=
{
<
ProtectedRoute
isAllowed
=
{
user
}
redirectUrl
=
{
"/log-in"
}
>
<
h1
>
my
tasks
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/profile/:id"
}
element
=
{
<
ProtectedRoute
isAllowed
=
{
user
}
redirectUrl
=
{
"/log-in"
}
>
<
h1
>
profile
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/workers-tasks"
}
element
=
{
<
ProtectedRoute
roles
=
{[
"superuser"
]}
redirectUrl
=
{
"/"
}
>
<
h1
>
workers
tasks
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/sign-up"
}
element
=
{
<
ProtectedRoute
roles
=
{[
"superuser"
]}
redirectUrl
=
{
"/"
}
>
<
h1
>
sign
-
up
page
<
/h1
>
<
/ProtectedRoute
>
}
/
>
<
Route
path
=
{
"/log-in"
}
element
=
{
<
h1
>
log
-
in
page
<
/h1>}/
>
<
Route
path
=
'*'
element
=
{
<
h1
>
404
<
/h1>}/
>
<
/Route
>
...
...
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