Commit 31e58e27 authored by Ermolaev Timur's avatar Ermolaev Timur

Merge branch 'task-127-fix/fix_header_menu' into 'development'

#127 Пофиксил менюшки в хедере

See merge request !100
parents 1ac76af3 39d8ad77
import { Button } from "@mui/material";
import { NavLink } from "react-router-dom";
import { superuserMenuButtons } from "../../../constants";
import ProfileBlock from "../ProfileBlock/ProfileBlock";
const AdminMenu = () => {
return <>
{superuserMenuButtons.map((button, i) => {
return (
<Button
key={i}
component={NavLink}
to={button.path}
color="inherit"
size="large"
>
{button.text}
</Button>
)
})}
<ProfileBlock />
</>
};
export default AdminMenu;
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { useDispatch, useSelector } from "react-redux";
import {NavLink, useNavigate} from "react-router-dom";
import { fetchUsersAllFields, logoutUser } from "../../../store/actions/usersActions";
import SwitchUserModal from "../../SwitchUserModal/SwitchUserModal";
import HasAccess from "../../UI/HasAccess/HasAccess";
const ProfileBlock = () => {
const dispatch = useDispatch();
......@@ -33,6 +34,11 @@ const ProfileBlock = () => {
handleClose()
handleOpenSwitchUser()
}
const navigateToRegisterUser =()=>{
navigate('/sign-up')
handleClose()
}
return <>
......@@ -51,6 +57,9 @@ const ProfileBlock = () => {
>
<MenuItem component={NavLink} to="/profile/test" color="inherit" onClick={handleClose}>Профиль</MenuItem>
<MenuItem onClick={()=>{switchUser()}}>Поменять юзера</MenuItem>
<HasAccess roles={['superuser']}>
<MenuItem onClick={()=>{navigateToRegisterUser()}}>Создать сотрудника</MenuItem>
</HasAccess>
<MenuItem onClick={()=>{logout()}}>Выйти</MenuItem>
</Menu>
<SwitchUserModal
......
......@@ -4,7 +4,6 @@ import { useSelector } from "react-redux";
import HasAccess from "../HasAccess/HasAccess";
import AnonymousMenu from "../../Menus/AnonymousMenu/AnonymousMenu";
import WorkerMenu from "../../Menus/WorkerMenu/WorkerMenu";
import AdminMenu from "../../Menus/AdminMenu/AdminMenu";
const AppToolbar = () => {
const user = useSelector(state => state.users.user);
......@@ -23,12 +22,9 @@ const AppToolbar = () => {
<HasAccess allowed={!user}>
<AnonymousMenu />
</HasAccess>
<HasAccess roles={['user']}>
<HasAccess allowed={user}>
<WorkerMenu />
</HasAccess>
<HasAccess roles={['superuser']}>
<AdminMenu />
</HasAccess>
</Toolbar>
</AppBar>
</Box>
......
......@@ -3,20 +3,11 @@ export const uploadsUrl = `${apiUrl}/uploads`;
export const workerMenuButtons = [
{ text: 'Проекты', path: '/projects' },
{ text: 'Мои задачи', path: '/my-tasks' },
{ text: 'Неделя', path: '/week' },
{ text: 'Месяц', path: '/month' },
{ text: 'Задачи Сотрудников', path: '/workers-tasks' },
{ 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 = [
......
......@@ -238,7 +238,7 @@ function MonthCalendar() {
await dispatch(fetchAllUserProjects())
setModal(true)
} else {
dispatch(setUserCalendarId(null))
setUserCalendarId(null)
}
}, [dispatch, user.id, userId])
......
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