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
37bf7db6
Commit
37bf7db6
authored
Dec 09, 2022
by
Ermolaev Timur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#92
Оптимизировал код в хедере, уменьшил количество кода
parent
341f950a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
117 additions
and
163 deletions
+117
-163
AdminMenu.js
planner-front/src/components/Menus/AdminMenu/AdminMenu.js
+18
-86
AnonymousMenu.js
...front/src/components/Menus/AnonymousMenu/AnonymousMenu.js
+14
-7
ProfileBlock.js
...r-front/src/components/Menus/ProfileBlock/ProfileBlock.js
+45
-0
WorkerMenu.js
planner-front/src/components/Menus/WorkerMenu/WorkerMenu.js
+19
-70
constants.js
planner-front/src/constants.js
+21
-0
No files found.
planner-front/src/components/Menus/AdminMenu/AdminMenu.js
View file @
37bf7db6
import
{
Button
,
Menu
,
MenuItem
}
from
"@mui/material"
;
import
{
Button
}
from
"@mui/material"
;
import
{
useState
}
from
"react"
;
import
{
NavLink
}
from
"react-router-dom"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
superuserMenuButtons
}
from
"../../../constants"
;
import
{
NavLink
,
useNavigate
}
from
"react-router-dom"
;
import
ProfileBlock
from
"../ProfileBlock/ProfileBlock"
;
import
{
logoutUser
}
from
"../../../store/actions/usersActions"
;
const
AdminMenu
=
()
=>
{
const
AdminMenu
=
()
=>
{
const
dispatch
=
useDispatch
();
const
navigate
=
useNavigate
()
const
[
anchorEl
,
setAnchorEl
]
=
useState
(
null
);
const
open
=
Boolean
(
anchorEl
);
const
user
=
useSelector
(
state
=>
state
.
users
.
user
)
const
handleClick
=
(
event
)
=>
{
setAnchorEl
(
event
.
currentTarget
);
};
const
handleClose
=
()
=>
{
setAnchorEl
(
null
);
};
const
logout
=
()
=>
{
dispatch
(
logoutUser
(
navigate
));
handleClose
()
}
return
<>
return
<>
<
Button
{
superuserMenuButtons
.
map
((
button
,
i
)
=>
{
component
=
{
NavLink
}
return
(
to
=
"/projects"
<
Button
color
=
"inherit"
key
=
{
i
}
size
=
"large"
component
=
{
NavLink
}
>
to
=
{
button
.
path
}
Проекты
color
=
"inherit"
<
/Button
>
size
=
"large"
<
Button
>
component
=
{
NavLink
}
{
button
.
text
}
to
=
"/week"
<
/Button
>
color
=
"inherit"
)
size
=
"large"
})}
>
<
ProfileBlock
/>
Неделя
<
/Button
>
<
Button
component
=
{
NavLink
}
to
=
"/month"
color
=
"inherit"
size
=
"large"
id
=
'test_month_header'
>
Месяц
<
/Button
>
<
Button
component
=
{
NavLink
}
to
=
"/my-tasks"
color
=
"inherit"
size
=
"large"
>
Мои
задачи
<
/Button
>
<
Button
component
=
{
NavLink
}
to
=
"/workers-tasks"
color
=
"inherit"
size
=
"large"
>
Задачи
сотрудников
<
/Button
>
<
Button
component
=
{
NavLink
}
to
=
"/sign-up"
color
=
"inherit"
size
=
"large"
>
Создать
сотрудника
<
/Button
>
<
Button
color
=
"inherit"
onClick
=
{
handleClick
}
id
=
'test_greetings'
>
Hello
,
{
user
?.
displayName
}
<
/Button
>
<
Menu
anchorEl
=
{
anchorEl
}
open
=
{
open
}
onClose
=
{
handleClose
}
>
<
MenuItem
component
=
{
NavLink
}
to
=
"/profile/test"
color
=
"inherit"
onClick
=
{
handleClose
}
>
Profile
<
/MenuItem
>
<
MenuItem
onClick
=
{
logout
}
>
Logout
<
/MenuItem
>
<
/Menu
>
<
/
>
<
/
>
};
};
...
...
planner-front/src/components/Menus/AnonymousMenu/AnonymousMenu.js
View file @
37bf7db6
import
{
Button
}
from
"@mui/material"
;
import
{
Button
}
from
"@mui/material"
;
import
{
NavLink
}
from
"react-router-dom"
;
import
{
NavLink
}
from
"react-router-dom"
;
import
{
anonymoysMenuButtons
}
from
"../../../constants"
;
const
AnonymousMenu
=
()
=>
{
const
AnonymousMenu
=
()
=>
{
return
<>
return
<>
<
Button
{
anonymoysMenuButtons
.
map
((
button
,
i
)
=>
{
component
=
{
NavLink
}
return
(
color
=
"inherit"
<
Button
to
=
"/sign-in"
key
=
{
i
}
>
component
=
{
NavLink
}
Вход
to
=
{
button
.
path
}
<
/Button
>
color
=
"inherit"
size
=
"large"
>
{
button
.
text
}
<
/Button
>
)
})}
<
/
>
<
/
>
};
};
...
...
planner-front/src/components/Menus/ProfileBlock/ProfileBlock.js
0 → 100644
View file @
37bf7db6
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"
;
const
ProfileBlock
=
()
=>
{
const
dispatch
=
useDispatch
();
const
navigate
=
useNavigate
()
const
[
anchorEl
,
setAnchorEl
]
=
useState
(
null
);
const
open
=
Boolean
(
anchorEl
);
const
user
=
useSelector
(
state
=>
state
.
users
.
user
)
const
handleClick
=
(
event
)
=>
{
setAnchorEl
(
event
.
currentTarget
);
};
const
handleClose
=
()
=>
{
setAnchorEl
(
null
);
};
const
logout
=
async
()
=>
{
await
dispatch
(
logoutUser
(
navigate
));
handleClose
()
}
return
<>
<
Button
color
=
"inherit"
onClick
=
{
handleClick
}
id
=
'test_greetings'
>
Hello
,
{
user
?.
displayName
}
<
/Button
>
<
Menu
anchorEl
=
{
anchorEl
}
open
=
{
open
}
onClose
=
{
handleClose
}
>
<
MenuItem
component
=
{
NavLink
}
to
=
"/profile/test"
color
=
"inherit"
onClick
=
{
handleClose
}
>
Profile
<
/MenuItem
>
<
MenuItem
onClick
=
{
logout
}
>
Logout
<
/MenuItem
>
<
/Menu
>
<
/
>
};
export
default
ProfileBlock
;
\ No newline at end of file
planner-front/src/components/Menus/WorkerMenu/WorkerMenu.js
View file @
37bf7db6
import
{
Button
,
Menu
,
MenuItem
}
from
"@mui/material"
;
import
{
Button
}
from
"@mui/material"
;
import
{
useState
}
from
"react"
;
import
{
NavLink
}
from
"react-router-dom"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
workerMenuButtons
}
from
"../../../constants"
;
import
{
NavLink
,
useNavigate
}
from
"react-router-dom"
;
import
ProfileBlock
from
"../ProfileBlock/ProfileBlock"
;
import
{
logoutUser
}
from
"../../../store/actions/usersActions"
;
const
WorkerMenu
=
()
=>
{
const
WorkerMenu
=
()
=>
{
const
dispatch
=
useDispatch
();
const
navigate
=
useNavigate
()
const
[
anchorEl
,
setAnchorEl
]
=
useState
(
null
);
const
open
=
Boolean
(
anchorEl
);
const
user
=
useSelector
(
state
=>
state
.
users
.
user
)
const
handleClick
=
(
event
)
=>
{
setAnchorEl
(
event
.
currentTarget
);
};
const
handleClose
=
()
=>
{
setAnchorEl
(
null
);
};
const
logout
=
()
=>
{
dispatch
(
logoutUser
(
navigate
));
handleClose
()
}
return
<>
return
<>
<
Button
{
workerMenuButtons
.
map
((
button
,
i
)
=>
{
component
=
{
NavLink
}
return
(
to
=
"/projects"
<
Button
color
=
"inherit"
key
=
{
i
}
size
=
"large"
component
=
{
NavLink
}
>
to
=
{
button
.
path
}
Проекты
color
=
"inherit"
<
/Button
>
size
=
"large"
<
Button
>
component
=
{
NavLink
}
{
button
.
text
}
to
=
"/week"
<
/Button
>
color
=
"inherit"
)
size
=
"large"
})}
>
Неделя
<
ProfileBlock
/>
<
/Button
>
<
Button
component
=
{
NavLink
}
to
=
"/month"
color
=
"inherit"
size
=
"large"
id
=
'test_month_header'
>
Месяц
<
/Button
>
<
Button
component
=
{
NavLink
}
to
=
"/my-tasks"
color
=
"inherit"
size
=
"large"
>
Мои
задачи
<
/Button
>
<
Button
color
=
"inherit"
onClick
=
{
handleClick
}
id
=
'test_greetings'
>
Hello
,
{
user
?.
displayName
}
<
/Button
>
<
Menu
anchorEl
=
{
anchorEl
}
open
=
{
open
}
onClose
=
{
handleClose
}
>
<
MenuItem
component
=
{
NavLink
}
to
=
"/profile/test"
color
=
"inherit"
onClick
=
{
handleClose
}
>
Profile
<
/MenuItem
>
<
MenuItem
onClick
=
{
logout
}
>
Logout
<
/MenuItem
>
<
/Menu
>
<
/
>
<
/
>
};
};
...
...
planner-front/src/constants.js
View file @
37bf7db6
export
const
apiUrl
=
"http://localhost:8000"
;
export
const
apiUrl
=
"http://localhost:8000"
;
export
const
uploadsUrl
=
`
${
apiUrl
}
/uploads`
;
export
const
uploadsUrl
=
`
${
apiUrl
}
/uploads`
;
export
const
workerMenuButtons
=
[
{
text
:
'Проекты'
,
path
:
'/projects'
},
{
text
:
'Неделя'
,
path
:
'/week'
},
{
text
:
'Месяц'
,
path
:
'/month'
},
{
text
:
'Мои задачи'
,
path
:
'/my-tasks'
}
]
export
const
superuserMenuButtons
=
[
{
text
:
'Проекты'
,
path
:
'/projects'
},
{
text
:
'Неделя'
,
path
:
'/week'
},
{
text
:
'Месяц'
,
path
:
'/month'
},
{
text
:
'Мои задачи'
,
path
:
'/my-tasks'
},
{
text
:
'Задачи Сотрудников'
,
path
:
'/workers-tasks'
},
{
text
:
'Создать Сотрудника'
,
path
:
'/sign-up'
}
]
export
const
anonymoysMenuButtons
=
[
{
text
:
'Вход'
,
path
:
'/sign-in'
},
]
\ No newline at end of file
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