fix: derive fp_scenario IDs from version snapshot, eliminate hardcoded UUIDs
Build pitch-deck / build-push-deploy (push) Successful in 1m30s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 33s
CI / test-python-voice (push) Successful in 32s
CI / test-bqas (push) Successful in 31s
Build pitch-deck / build-push-deploy (push) Successful in 1m30s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-consent (push) Successful in 33s
CI / test-python-voice (push) Successful in 32s
CI / test-bqas (push) Successful in 31s
The fm_scenarios array in each pitch version snapshot already stores the fp_scenario IDs directly (same pattern 1 Mio used). Wandeldarlehen snapshots were missing Bear/Bull entries — updated in DB to add them. - /api/data: include fp_scenarios in version response (was omitted) - PitchDeck: derive fpBaseScenarioId from data.fp_scenarios - useFpKPIs: accept fpBaseScenarioId instead of isWandeldarlehen boolean - AssumptionsSlide: find Bear/Base/Bull by name from fpScenarios prop - FinanzplanSlide: initialize from fpBaseScenarioId, use version scenarios for selector - FinancialsSlide / ExecutiveSummarySlide: pass fpBaseScenarioId to hook - types: add FpScenarioRef + fp_scenarios field to PitchData No UUID hardcoded in any component. Adding a new pitch version only requires setting the correct fp_scenario IDs in its fm_scenarios snapshot. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,14 +31,14 @@ interface SheetRow {
|
||||
* Loads annual KPIs directly from fp_* tables (source of truth).
|
||||
* Returns a map of year keys (y2026-y2030) to KPI objects.
|
||||
*/
|
||||
export function useFpKPIs(isWandeldarlehen?: boolean) {
|
||||
export function useFpKPIs(fpBaseScenarioId?: string | null) {
|
||||
const [kpis, setKpis] = useState<Record<string, FpAnnualKPIs>>({})
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
try {
|
||||
const param = isWandeldarlehen ? '?scenarioId=c0000000-0000-0000-0000-000000000200' : ''
|
||||
const param = fpBaseScenarioId ? `?scenarioId=${fpBaseScenarioId}` : ''
|
||||
const [guvRes, liqRes, persRes, kundenRes] = await Promise.all([
|
||||
fetch(`/api/finanzplan/guv${param}`, { cache: 'no-store' }),
|
||||
fetch(`/api/finanzplan/liquiditaet${param}`, { cache: 'no-store' }),
|
||||
@@ -102,7 +102,7 @@ export function useFpKPIs(isWandeldarlehen?: boolean) {
|
||||
setLoading(false)
|
||||
}
|
||||
load()
|
||||
}, [isWandeldarlehen])
|
||||
}, [fpBaseScenarioId])
|
||||
|
||||
// Use of Funds: compute spending breakdown m8-m24 (funding period)
|
||||
const [useOfFunds, setUseOfFunds] = useState<Array<{ category: string; label_de: string; label_en: string; percentage: number }>>([])
|
||||
@@ -110,7 +110,7 @@ export function useFpKPIs(isWandeldarlehen?: boolean) {
|
||||
useEffect(() => {
|
||||
async function loadUoF() {
|
||||
try {
|
||||
const param = isWandeldarlehen ? '?scenarioId=c0000000-0000-0000-0000-000000000200' : ''
|
||||
const param = fpBaseScenarioId ? `?scenarioId=${fpBaseScenarioId}` : ''
|
||||
const [persRes, betriebRes, investRes] = await Promise.all([
|
||||
fetch(`/api/finanzplan/personalkosten${param}`, { cache: 'no-store' }),
|
||||
fetch(`/api/finanzplan/betriebliche${param}`, { cache: 'no-store' }),
|
||||
@@ -168,7 +168,7 @@ export function useFpKPIs(isWandeldarlehen?: boolean) {
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
loadUoF()
|
||||
}, [isWandeldarlehen])
|
||||
}, [fpBaseScenarioId])
|
||||
|
||||
const last = kpis.y2030
|
||||
return { kpis, loading, last, useOfFunds }
|
||||
|
||||
@@ -114,6 +114,14 @@ export interface PitchProduct {
|
||||
operating_cost_eur: number
|
||||
}
|
||||
|
||||
export interface FpScenarioRef {
|
||||
id: string
|
||||
name: string
|
||||
is_default?: boolean
|
||||
color?: string
|
||||
description?: string
|
||||
}
|
||||
|
||||
export interface PitchData {
|
||||
company: PitchCompany
|
||||
team: PitchTeamMember[]
|
||||
@@ -125,6 +133,7 @@ export interface PitchData {
|
||||
metrics: PitchMetric[]
|
||||
funding: PitchFunding
|
||||
products: PitchProduct[]
|
||||
fp_scenarios?: FpScenarioRef[]
|
||||
}
|
||||
|
||||
// Financial Model Types
|
||||
|
||||
Reference in New Issue
Block a user