Skip to content

Commit

Permalink
add a list for the superuser options
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewakiv committed Oct 10, 2024
1 parent bb31058 commit 7c44f5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
10 changes: 0 additions & 10 deletions FrontEnd/src/context/AuthContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ export function AuthProvider({ children }) {
if (data) {
setUser(data);
setIsStaff(data.is_staff);
}
if (error) {
setUser(null);
}
setLoading(false);
}, [data, error]);

useEffect(() => {
if (data) {
setUser(data);
setIsSuperUser(data.is_superuser);
}
if (error) {
Expand Down
21 changes: 11 additions & 10 deletions FrontEnd/src/pages/AdminPage/Menu/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ const MENU = [
title: 'Зміна часу автомодерації',
link: '/customadmin/automoderation/'
},
// {
// id: 'am5',
// title: 'Пошта адміністратора',
// link: '/customadmin/email/'
// }
];

const SUPERUSER_MENU = [
{
id: 'am5',
title: 'Пошта адміністратора',
link: '/customadmin/email/'
}
];

function Menu() {
Expand All @@ -49,11 +52,9 @@ function Menu() {
{MENU.map((element) => (
<Link className={css['menu-section-element']} key={element.id} to={element.link}>{element.title}</Link>
))}
{isSuperUser && (
<Link className={css['menu-section-element']} to="/customadmin/email/">
Пошта адміністратора
</Link>
)}
{isSuperUser && SUPERUSER_MENU.map((element) => (
<Link className={css['menu-section-element']} key={element.id} to={element.link}>{element.title}</Link>
))}
<div className={css['menu-section-divider']}></div>
<button className={css['menu-section-logout']} onClick={handleLogout}>Вихід</button>
</div>
Expand Down

0 comments on commit 7c44f5b

Please sign in to comment.