feat(docgen): wire CMP, Loeschfristen, UseCases into Document Generator
Connect three previously siloed modules to the contextBridge: - CookieBanner → CONSENT (analytics tools, marketing partners) + FEATURES (CMP_NAME, HAS_FUNCTIONAL_COOKIES) - RetentionPolicies → PRIVACY.ANALYTICS_RETENTION_MONTHS (from actual Loeschfristen data) - UseCases → FEATURES flags (HAS_ACCOUNT, HAS_PAYMENTS, HAS_NEWSLETTER, HAS_SOCIAL_MEDIA) Previously all FEATURES were hardcoded false/empty in EMPTY_CONTEXT. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,78 @@ function DocumentGeneratorPageInner() {
|
|||||||
}
|
}
|
||||||
}, [state?.companyProfile])
|
}, [state?.companyProfile])
|
||||||
|
|
||||||
|
// ── MODULE WIRING: CookieBanner → CONSENT + FEATURES ─────────────────────
|
||||||
|
useEffect(() => {
|
||||||
|
const banner = state?.cookieBanner
|
||||||
|
if (!banner) return
|
||||||
|
const cats = banner.categories || []
|
||||||
|
const analyticsTools = cats
|
||||||
|
.filter((c) => c.id === 'analytics' || c.id === 'statistics')
|
||||||
|
.flatMap((c) => c.cookies?.map((ck) => ck.name) ?? [])
|
||||||
|
const marketingTools = cats
|
||||||
|
.filter((c) => c.id === 'marketing')
|
||||||
|
.flatMap((c) => c.cookies?.map((ck) => ck.name) ?? [])
|
||||||
|
const hasFunctional = cats.some((c) => c.id === 'functional')
|
||||||
|
|
||||||
|
setContext((prev) => ({
|
||||||
|
...prev,
|
||||||
|
CONSENT: {
|
||||||
|
...prev.CONSENT,
|
||||||
|
ANALYTICS_TOOLS: analyticsTools.length > 0 ? analyticsTools.join(', ') : prev.CONSENT.ANALYTICS_TOOLS,
|
||||||
|
MARKETING_PARTNERS: marketingTools.length > 0 ? marketingTools.join(', ') : prev.CONSENT.MARKETING_PARTNERS,
|
||||||
|
},
|
||||||
|
FEATURES: {
|
||||||
|
...prev.FEATURES,
|
||||||
|
CMP_NAME: 'BreakPilot CMP',
|
||||||
|
CMP_LOGS_CONSENTS: true,
|
||||||
|
HAS_FUNCTIONAL_COOKIES: hasFunctional || prev.FEATURES.HAS_FUNCTIONAL_COOKIES,
|
||||||
|
CONSENT_WITHDRAWAL_PATH: 'Footer-Link "Cookie-Einstellungen"',
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}, [state?.cookieBanner])
|
||||||
|
|
||||||
|
// ── MODULE WIRING: Loeschfristen → PRIVACY retention ──────────────────────
|
||||||
|
useEffect(() => {
|
||||||
|
const policies = state?.retentionPolicies
|
||||||
|
if (!policies || policies.length === 0) return
|
||||||
|
const maxMonths = policies.reduce((max, p) => {
|
||||||
|
const match = p.retentionPeriod?.match(/(\d+)\s*(Monat|Jahr|Tag)/i)
|
||||||
|
if (!match) return max
|
||||||
|
const val = parseInt(match[1], 10)
|
||||||
|
const unit = match[2].toLowerCase()
|
||||||
|
const months = unit.startsWith('jahr') ? val * 12 : unit.startsWith('tag') ? Math.ceil(val / 30) : val
|
||||||
|
return Math.max(max, months)
|
||||||
|
}, 0)
|
||||||
|
if (maxMonths > 0) {
|
||||||
|
setContext((prev) => ({
|
||||||
|
...prev,
|
||||||
|
PRIVACY: { ...prev.PRIVACY, ANALYTICS_RETENTION_MONTHS: maxMonths },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}, [state?.retentionPolicies])
|
||||||
|
|
||||||
|
// ── MODULE WIRING: UseCases → FEATURES flags ─────────────────────────────
|
||||||
|
useEffect(() => {
|
||||||
|
const useCases = state?.useCases
|
||||||
|
if (!useCases || useCases.length === 0) return
|
||||||
|
const allText = useCases.map((uc) => `${uc.name} ${uc.description}`).join(' ').toLowerCase()
|
||||||
|
const hasAccount = allText.includes('account') || allText.includes('konto') || allText.includes('registrier')
|
||||||
|
const hasPayments = allText.includes('zahlung') || allText.includes('payment') || allText.includes('stripe') || allText.includes('paypal')
|
||||||
|
const hasNewsletter = allText.includes('newsletter') || allText.includes('mailchimp') || allText.includes('e-mail-marketing')
|
||||||
|
const hasSocial = allText.includes('social') || allText.includes('linkedin') || allText.includes('facebook') || allText.includes('instagram')
|
||||||
|
|
||||||
|
setContext((prev) => ({
|
||||||
|
...prev,
|
||||||
|
FEATURES: {
|
||||||
|
...prev.FEATURES,
|
||||||
|
HAS_ACCOUNT: hasAccount || prev.FEATURES.HAS_ACCOUNT,
|
||||||
|
HAS_PAYMENTS: hasPayments || prev.FEATURES.HAS_PAYMENTS,
|
||||||
|
HAS_NEWSLETTER: hasNewsletter || prev.FEATURES.HAS_NEWSLETTER,
|
||||||
|
HAS_SOCIAL_MEDIA: hasSocial || prev.FEATURES.HAS_SOCIAL_MEDIA,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}, [state?.useCases])
|
||||||
|
|
||||||
// Pre-fill extra placeholders from Einwilligungen data points
|
// Pre-fill extra placeholders from Einwilligungen data points
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedDataPointsData && selectedDataPointsData.length > 0) {
|
if (selectedDataPointsData && selectedDataPointsData.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user