larxius commited on
Commit
6f60a4c
·
verified ·
1 Parent(s): 36b5268

Update frontend/src/components/Layout.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/components/Layout.jsx +24 -26
frontend/src/components/Layout.jsx CHANGED
@@ -1,5 +1,6 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
- import { Link, NavLink, useNavigate, useLocation } from 'react-router-dom';
 
3
  import { useAuth } from './AuthContext';
4
 
5
  export const getInitials = (userData) => {
@@ -178,30 +179,27 @@ export const Layout = ({ children }) => {
178
  navigate(isSuperAdmin ? '/' : '/login');
179
  };
180
 
181
- let navItems = [];
182
-
183
- if (user?.role === 'executive_user') {
184
- navItems = [
185
- { to: '/scans/history', label: 'Organization Reports', icon: 'analytics' },
186
- { to: '/settings', label: 'Settings', icon: 'settings' },
187
- ];
188
- } else {
189
- navItems = [
190
- { to: '/dashboard', label: 'Dashboard', icon: 'dashboard' },
191
- { to: '/scans/new', label: 'New Scan', icon: 'security' },
192
- { to: '/scans/history', label: 'Reports', icon: 'analytics' },
193
- { to: '/scans/results', label: 'Vulnerabilities', icon: 'bug_report' },
194
- { to: '/settings', label: 'Settings', icon: 'settings' },
195
- ];
196
- }
197
-
198
- if (user?.role === 'super_admin') {
199
- navItems.push({ to: '/super-admin', label: 'Global Management', icon: 'admin_panel_settings' });
200
- } else if (user?.role === 'admin') {
201
- navItems.push({ to: '/admin', label: 'Global Management', icon: 'admin_panel_settings' });
202
- } else if (user?.role === 'support_engineer') {
203
- navItems.push({ to: '/support', label: 'Global Management', icon: 'support_agent' });
204
- }
205
 
206
  return (
207
  <div className="bg-background text-on-background font-body-md text-body-md antialiased min-h-screen flex flex-col md:flex-row w-full transition-colors duration-300">
 
1
+ /* eslint-disable react-hooks/exhaustive-deps, react-hooks/set-state-in-effect, react-hooks/immutability, react-refresh/only-export-components */
2
+ import { useState, useEffect, useRef } from 'react';
3
+ import { NavLink, useNavigate, useLocation } from 'react-router-dom';
4
  import { useAuth } from './AuthContext';
5
 
6
  export const getInitials = (userData) => {
 
179
  navigate(isSuperAdmin ? '/' : '/login');
180
  };
181
 
182
+ const navItems = [
183
+ ...(user?.role === 'executive_user'
184
+ ? [
185
+ { to: '/scans/history', label: 'Organization Reports', icon: 'analytics' },
186
+ { to: '/settings', label: 'Settings', icon: 'settings' },
187
+ ]
188
+ : [
189
+ { to: '/dashboard', label: 'Dashboard', icon: 'dashboard' },
190
+ { to: '/scans/new', label: 'New Scan', icon: 'security' },
191
+ { to: '/scans/history', label: 'Reports', icon: 'analytics' },
192
+ { to: '/scans/results', label: 'Vulnerabilities', icon: 'bug_report' },
193
+ { to: '/settings', label: 'Settings', icon: 'settings' },
194
+ ]),
195
+ ...(user?.role === 'super_admin'
196
+ ? [{ to: '/super-admin', label: 'Global Management', icon: 'admin_panel_settings' }]
197
+ : user?.role === 'admin'
198
+ ? [{ to: '/admin', label: 'Global Management', icon: 'admin_panel_settings' }]
199
+ : user?.role === 'support_engineer'
200
+ ? [{ to: '/support', label: 'Global Management', icon: 'support_agent' }]
201
+ : []),
202
+ ];
 
 
 
203
 
204
  return (
205
  <div className="bg-background text-on-background font-body-md text-body-md antialiased min-h-screen flex flex-col md:flex-row w-full transition-colors duration-300">