Commit 39d8ad77 authored by Ermolaev Timur's avatar Ermolaev Timur

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

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