resolve issues with new features
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Box, Tabs, Tab, Typography } from '@mui/material';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
import { Navigate, useSearchParams } from 'react-router-dom';
|
||||
import DashboardLayout from '../components/dashboard/DashboardLayout';
|
||||
import ServiceManagerTab from '../components/admin/ServiceManagerTab';
|
||||
import SystemHealthTab from '../components/admin/SystemHealthTab';
|
||||
@@ -21,8 +21,19 @@ function TabPanel({ children, value, index }: TabPanelProps) {
|
||||
return <Box sx={{ pt: 3 }}>{children}</Box>;
|
||||
}
|
||||
|
||||
const ADMIN_TAB_COUNT = 6;
|
||||
|
||||
function AdminDashboard() {
|
||||
const [tab, setTab] = useState(0);
|
||||
const [searchParams] = useSearchParams();
|
||||
const [tab, setTab] = useState(() => {
|
||||
const t = Number(searchParams.get('tab'));
|
||||
return t >= 0 && t < ADMIN_TAB_COUNT ? t : 0;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const t = Number(searchParams.get('tab'));
|
||||
if (t >= 0 && t < ADMIN_TAB_COUNT) setTab(t);
|
||||
}, [searchParams]);
|
||||
const { user } = useAuth();
|
||||
|
||||
const isAdmin = user?.groups?.includes('dashboard_admin') ?? false;
|
||||
|
||||
Reference in New Issue
Block a user