2026-07-08 12:55:37 +02:00
|
|
|
import { Navigate, Outlet } from 'react-router-dom'
|
2026-07-25 10:52:12 +02:00
|
|
|
import { useMemo } from 'react'
|
2026-07-10 14:26:14 +02:00
|
|
|
import { ModeAreaShell } from '../../components/ModeAreaShell.jsx'
|
|
|
|
|
import { ModeAreaNav } from '../../components/ModeAreaNav.jsx'
|
2026-07-08 12:55:37 +02:00
|
|
|
import { ModeShell } from '../../components/ModeShell.jsx'
|
2026-07-10 14:26:14 +02:00
|
|
|
import { WORK_NAV_ITEMS, resolveWorkNavActiveKey } from '../../config/workNav.js'
|
2026-07-12 16:27:34 +02:00
|
|
|
import { useProgramScope } from '../../context/ProgramScopeContext.jsx'
|
2026-07-25 10:52:12 +02:00
|
|
|
import { useMethodUiContext } from '../../hooks/useMethodUiContext.js'
|
|
|
|
|
import { resolveWorkNavItemsFromProfile } from '../../registry/resolveOperatingProfile.js'
|
2026-07-12 19:20:06 +02:00
|
|
|
|
|
|
|
|
function WorkAreaNav() {
|
|
|
|
|
const { initiativeId } = useProgramScope()
|
2026-07-25 10:52:12 +02:00
|
|
|
const { operatingContext, hasActiveSprint, loading } = useMethodUiContext()
|
2026-07-12 19:20:06 +02:00
|
|
|
|
2026-07-25 10:52:12 +02:00
|
|
|
const navItems = useMemo(() => {
|
|
|
|
|
if (!initiativeId) return WORK_NAV_ITEMS
|
|
|
|
|
if (loading && !operatingContext) return WORK_NAV_ITEMS
|
|
|
|
|
return resolveWorkNavItemsFromProfile({ operatingContext, hasActiveSprint })
|
|
|
|
|
}, [initiativeId, loading, operatingContext, hasActiveSprint])
|
2026-07-12 19:20:06 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ModeAreaNav
|
|
|
|
|
modeLabel="Ausführen"
|
|
|
|
|
items={navItems}
|
|
|
|
|
resolveActiveKey={resolveWorkNavActiveKey}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-07-08 12:55:37 +02:00
|
|
|
|
|
|
|
|
export function WorkLayout() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="app-page">
|
|
|
|
|
<ModeShell modeKey="work" />
|
2026-07-12 19:20:06 +02:00
|
|
|
<ModeAreaShell nav={<WorkAreaNav />}>
|
2026-07-10 14:26:14 +02:00
|
|
|
<Outlet />
|
|
|
|
|
</ModeAreaShell>
|
2026-07-08 12:55:37 +02:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function WorkIndexRedirect() {
|
2026-07-12 19:20:06 +02:00
|
|
|
const { initiativeId, hrefWithScope } = useProgramScope()
|
2026-07-25 10:52:12 +02:00
|
|
|
const { workDefaultRoute, loading, operatingContext } = useMethodUiContext()
|
2026-07-12 16:27:34 +02:00
|
|
|
|
2026-07-25 10:52:12 +02:00
|
|
|
if (!initiativeId) {
|
|
|
|
|
return <Navigate to="/work/today" replace />
|
|
|
|
|
}
|
2026-07-12 16:27:34 +02:00
|
|
|
|
2026-07-25 10:52:12 +02:00
|
|
|
if (loading && !operatingContext) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <Navigate to={hrefWithScope(workDefaultRoute)} replace />
|
2026-07-08 12:55:37 +02:00
|
|
|
}
|