refactoring

This commit is contained in:
2025-11-10 16:44:54 +01:00
parent c2710f0a67
commit 89e7f77a4e
11 changed files with 807 additions and 10 deletions

View File

@@ -4,23 +4,26 @@ const NavigationTabs = ({ isAdmin, onProtectedNavigate }) => {
const location = useLocation();
const navigate = useNavigate();
if (!isAdmin) {
return null;
}
const tabs = [
{ to: '/', label: 'Konfiguration' },
{ to: '/admin', label: 'Admin' }
{ to: '/store-watch', label: 'Betriebs-Monitoring' }
];
if (isAdmin) {
tabs.push({ to: '/admin', label: 'Admin' });
}
const handleClick = (event, to) => {
event.preventDefault();
if (to === location.pathname) {
return;
}
onProtectedNavigate(`zur Seite "${tabs.find((tab) => tab.to === to)?.label || ''}" zu wechseln`, () =>
navigate(to)
);
const label = tabs.find((tab) => tab.to === to)?.label || '';
const proceed = () => navigate(to);
if (onProtectedNavigate) {
onProtectedNavigate(`zur Seite "${label}" zu wechseln`, proceed);
return;
}
proceed();
};
return (