This commit is contained in:
seb
2026-06-23 11:44:14 +02:00
parent 8c3e70d383
commit e84ba761c7
14 changed files with 118 additions and 55 deletions

View File

@@ -4,48 +4,18 @@ import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom';
import { useAuth } from './auth/useAuth';
import LoginPage from './components/LoginPage';
import AppShell from './components/AppShell';
import SectionPage from './pages/SectionPage';
import SubPage from './pages/SubPage';
import { NAV_ITEMS, SUB_NAV } from './nav';
function sectionRoutes(path) {
const subNav = SUB_NAV[path];
const routePath = path === '/' ? undefined : path.slice(1);
if (subNav) {
return (
<Route key={path} path={routePath} element={<SectionPage sectionPath={path} />}>
{subNav.map(({ segment, label }) =>
segment ? (
<Route
key={segment}
path={segment}
element={<SubPage title={label} />}
/>
) : (
<Route key="index" index element={<SubPage title={label} />} />
),
)}
</Route>
);
}
const label = NAV_ITEMS.find((n) => n.path === path)?.label;
if (path === '/') {
return (
<Route key={path} index element={<SectionPage sectionPath={path}><SubPage title={label} /></SectionPage>} />
);
}
return (
<Route
key={path}
path={routePath}
element={<SectionPage sectionPath={path}><SubPage title={label} /></SectionPage>}
/>
);
}
import SectionLayout from './components/SectionLayout';
import HomePage from './pages/index';
import ArtikelUebersichtPage from './pages/artikel/index';
import ArtikelKategorienPage from './pages/artikel/kategorien';
import ArtikelLagerPage from './pages/artikel/lager';
import LieferungPage from './pages/lieferung/index';
import AuftragAktivePage from './pages/auftrag/index';
import AuftragArchivPage from './pages/auftrag/archiv';
import KundeListePage from './pages/kunde/index';
import KundeGruppenPage from './pages/kunde/gruppen';
import KundeKontaktePage from './pages/kunde/kontakte';
import InfosPage from './pages/infos/index';
export default function App() {
const { status } = useAuth();
@@ -74,7 +44,23 @@ export default function App() {
<BrowserRouter>
<Routes>
<Route path="/" element={<AppShell />}>
{NAV_ITEMS.map((item) => sectionRoutes(item.path))}
<Route index element={<HomePage />} />
<Route path="lieferung" element={<LieferungPage />} />
<Route path="infos" element={<InfosPage />} />
<Route path="artikel" element={<SectionLayout sectionPath="/artikel" />}>
<Route index element={<ArtikelUebersichtPage />} />
<Route path="kategorien" element={<ArtikelKategorienPage />} />
<Route path="lager" element={<ArtikelLagerPage />} />
</Route>
<Route path="auftrag" element={<SectionLayout sectionPath="/auftrag" />}>
<Route index element={<AuftragAktivePage />} />
<Route path="archiv" element={<AuftragArchivPage />} />
</Route>
<Route path="kunde" element={<SectionLayout sectionPath="/kunde" />}>
<Route index element={<KundeListePage />} />
<Route path="gruppen" element={<KundeGruppenPage />} />
<Route path="kontakte" element={<KundeKontaktePage />} />
</Route>
<Route path="*" element={<Navigate to="/" replace />} />
</Route>
</Routes>

View File

@@ -1,8 +1,8 @@
import { Outlet, useLocation } from 'react-router-dom';
import PageLayout from '../components/PageLayout';
import PageLayout from './PageLayout';
import { NAV_ITEMS, SUB_NAV } from '../nav';
export default function SectionPage({ sectionPath, children }) {
export default function SectionLayout({ sectionPath }) {
const { pathname } = useLocation();
const title = NAV_ITEMS.find((item) => item.path === sectionPath)?.label ?? '';
const subNav = SUB_NAV[sectionPath];
@@ -14,7 +14,7 @@ export default function SectionPage({ sectionPath, children }) {
return (
<PageLayout title={pageTitle} subNav={subNav} basePath={sectionPath}>
{children ?? <Outlet />}
<Outlet />
</PageLayout>
);
}

View File

@@ -1,9 +0,0 @@
import Typography from '@mui/material/Typography';
export default function SubPage({ title, description }) {
return (
<Typography color="text.secondary">
{description ?? `${title} — Inhalt folgt.`}
</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function ArtikelUebersichtPage() {
return (
<Typography color="text.secondary">Übersicht — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function ArtikelKategorienPage() {
return (
<Typography color="text.secondary">Kategorien — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function ArtikelLagerPage() {
return (
<Typography color="text.secondary">Lager — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function AuftragArchivPage() {
return (
<Typography color="text.secondary">Archiv — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function AuftragAktivePage() {
return (
<Typography color="text.secondary">Aktive Aufträge — Inhalt folgt.</Typography>
);
}

10
src/pages/index.jsx Normal file
View File

@@ -0,0 +1,10 @@
import Typography from '@mui/material/Typography';
import PageLayout from '../components/PageLayout';
export default function HomePage() {
return (
<PageLayout title="Home">
<Typography color="text.secondary">Home — Inhalt folgt.</Typography>
</PageLayout>
);
}

10
src/pages/infos/index.jsx Normal file
View File

@@ -0,0 +1,10 @@
import Typography from '@mui/material/Typography';
import PageLayout from '../../components/PageLayout';
export default function InfosPage() {
return (
<PageLayout title="Infos">
<Typography color="text.secondary">Infos — Inhalt folgt.</Typography>
</PageLayout>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function KundeGruppenPage() {
return (
<Typography color="text.secondary">Gruppen — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function KundeListePage() {
return (
<Typography color="text.secondary">Kundenliste — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,7 @@
import Typography from '@mui/material/Typography';
export default function KundeKontaktePage() {
return (
<Typography color="text.secondary">Kontakte — Inhalt folgt.</Typography>
);
}

View File

@@ -0,0 +1,10 @@
import Typography from '@mui/material/Typography';
import PageLayout from '../../components/PageLayout';
export default function LieferungPage() {
return (
<PageLayout title="Lieferung">
<Typography color="text.secondary">Lieferung — Inhalt folgt.</Typography>
</PageLayout>
);
}