AP2.3b: Frontend Profile Resolver — Operating Context statt methodUiDefaults.
Test Suite / pytest-backend (push) Waiting to run
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Has been cancelled
Test Suite / pytest-backend (push) Waiting to run
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4ad908bfbf
commit
90934453e6
7 files changed
+282
-32
No files matched your search
@@ -1,24 +1,21 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { getInitiative } from '../api/initiatives.js'
|
||||
import { getInitiativeOperatingContext } from '../api/initiatives.js'
|
||||
import { getActiveWorkCycle } from '../api/workCycles.js'
|
||||
import { getInitiativeSteeringSnapshot } from '../api/initiatives.js'
|
||||
import { useProgramScope } from '../context/ProgramScopeContext.jsx'
|
||||
import { resolveMethodUiDefaults } from '../config/methodUiDefaults.js'
|
||||
import { resolveOperatingProfileFromInput } from '../registry/resolveOperatingProfile.js'
|
||||
|
||||
/**
|
||||
* Lädt Archetyp/Methode für methodengebundene UI (AP1.9d).
|
||||
* Lädt Operating Context für methodengebundene UI (AP2.3b).
|
||||
*/
|
||||
export function useMethodUiContext() {
|
||||
const { initiativeId } = useProgramScope()
|
||||
const [archetypeKey, setArchetypeKey] = useState(null)
|
||||
const [methodKey, setMethodKey] = useState(null)
|
||||
const [operatingContext, setOperatingContext] = useState(null)
|
||||
const [hasActiveSprint, setHasActiveSprint] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!initiativeId) {
|
||||
setArchetypeKey(null)
|
||||
setMethodKey(null)
|
||||
setOperatingContext(null)
|
||||
setHasActiveSprint(false)
|
||||
return undefined
|
||||
}
|
||||
@@ -27,20 +24,17 @@ export function useMethodUiContext() {
|
||||
setLoading(true)
|
||||
|
||||
Promise.all([
|
||||
getInitiative(initiativeId),
|
||||
getInitiativeOperatingContext(initiativeId).catch(() => null),
|
||||
getActiveWorkCycle(initiativeId).catch(() => null),
|
||||
getInitiativeSteeringSnapshot(initiativeId).catch(() => null),
|
||||
])
|
||||
.then(([initiative, activeCycle, snapshot]) => {
|
||||
.then(([context, activeCycle]) => {
|
||||
if (cancelled) return
|
||||
setArchetypeKey(initiative?.archetype_key || null)
|
||||
setMethodKey(snapshot?.method_key || null)
|
||||
setOperatingContext(context)
|
||||
setHasActiveSprint(Boolean(activeCycle?.id))
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) {
|
||||
setArchetypeKey(null)
|
||||
setMethodKey(null)
|
||||
setOperatingContext(null)
|
||||
setHasActiveSprint(false)
|
||||
}
|
||||
})
|
||||
@@ -53,19 +47,25 @@ export function useMethodUiContext() {
|
||||
}
|
||||
}, [initiativeId])
|
||||
|
||||
const input = useMemo(
|
||||
() => ({ archetypeKey, methodKey, hasActiveSprint }),
|
||||
[archetypeKey, methodKey, hasActiveSprint],
|
||||
const profileInput = useMemo(
|
||||
() => ({ operatingContext, hasActiveSprint }),
|
||||
[operatingContext, hasActiveSprint],
|
||||
)
|
||||
|
||||
const defaults = useMemo(() => resolveMethodUiDefaults(input), [input])
|
||||
const profile = useMemo(
|
||||
() => resolveOperatingProfileFromInput(profileInput),
|
||||
[profileInput],
|
||||
)
|
||||
|
||||
return {
|
||||
initiativeId,
|
||||
archetypeKey,
|
||||
methodKey,
|
||||
archetypeKey: operatingContext?.archetype_key || null,
|
||||
methodKey: operatingContext?.method_key || null,
|
||||
methodProfileKey: operatingContext?.method_profile_key || null,
|
||||
operatingContext,
|
||||
hasActiveSprint,
|
||||
loading,
|
||||
...defaults,
|
||||
dataSlices: profile.dataSlices,
|
||||
...profile,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user