docs: Archetyp-gesteuerte UI-Navigation verankern
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Failing after 3m50s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Failing after 3m50s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
ARCHETYPE_UI_NAVIGATION_v0.1 plus Verweise in Spec-Template, README und Programm-Dokument.
This commit is contained in:
1 parent
11b7128204
commit
97fab2c76d
6 files changed
+175
-50
No files matched your search
@@ -1,61 +1,31 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { getInitiativeOperatingContext } from '../api/initiatives.js'
|
||||
import { getActiveWorkCycle } from '../api/workCycles.js'
|
||||
import { useMemo } from 'react'
|
||||
import { useProgramScope } from '../context/ProgramScopeContext.jsx'
|
||||
import { useOptionalInitiativeOperations } from '../context/InitiativeOperationsContext.jsx'
|
||||
import { resolveOperatingProfileFromInput } from '../registry/resolveOperatingProfile.js'
|
||||
|
||||
/**
|
||||
* Lädt Operating Context für methodengebundene UI (AP2.3b).
|
||||
* Methoden-/Archetyp-UI aus dem gemeinsamen InitiativeOperationsProvider (AP2.3b).
|
||||
* Kein separater Fetch pro Komponente — verhindert Route-Gate-Races beim Modus-Wechsel.
|
||||
*/
|
||||
export function useMethodUiContext() {
|
||||
const { initiativeId } = useProgramScope()
|
||||
const [operatingContext, setOperatingContext] = useState(null)
|
||||
const [hasActiveSprint, setHasActiveSprint] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
const ops = useOptionalInitiativeOperations()
|
||||
|
||||
useEffect(() => {
|
||||
if (!initiativeId) {
|
||||
setOperatingContext(null)
|
||||
setHasActiveSprint(false)
|
||||
return undefined
|
||||
}
|
||||
|
||||
let cancelled = false
|
||||
setLoading(true)
|
||||
|
||||
Promise.all([
|
||||
getInitiativeOperatingContext(initiativeId).catch(() => null),
|
||||
getActiveWorkCycle(initiativeId).catch(() => null),
|
||||
])
|
||||
.then(([context, activeCycle]) => {
|
||||
if (cancelled) return
|
||||
setOperatingContext(context)
|
||||
setHasActiveSprint(Boolean(activeCycle?.id))
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) {
|
||||
setOperatingContext(null)
|
||||
setHasActiveSprint(false)
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
if (!cancelled) setLoading(false)
|
||||
})
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [initiativeId])
|
||||
const operatingContext = ops?.operatingContext ?? null
|
||||
const hasActiveSprint = Boolean(ops?.activeWorkCycle?.id)
|
||||
const loading = Boolean(initiativeId && ops?.loading)
|
||||
|
||||
const profileInput = useMemo(
|
||||
() => ({ operatingContext, hasActiveSprint }),
|
||||
[operatingContext, hasActiveSprint],
|
||||
)
|
||||
|
||||
const profile = useMemo(
|
||||
() => resolveOperatingProfileFromInput(profileInput),
|
||||
[profileInput],
|
||||
)
|
||||
const profile = useMemo(() => {
|
||||
if (ops?.operatingProfile) {
|
||||
return ops.operatingProfile
|
||||
}
|
||||
return resolveOperatingProfileFromInput(profileInput)
|
||||
}, [ops?.operatingProfile, profileInput])
|
||||
|
||||
return {
|
||||
initiativeId,
|
||||
|
||||
Reference in new issue
Block a user