All four files split into focused sibling modules so every file lands
comfortably under the 300-LOC soft target (hard cap 500):
hooks.ts (474→43) → hooks-core / hooks-dsgvo / hooks-compliance
hooks-rag-security / hooks-ui
dsr-portal.ts (464→129) → dsr-portal-translations / dsr-portal-render
provider.tsx (462→247) → provider-effects / provider-callbacks
sync.ts (435→299) → sync-storage / sync-conflict
Zero behaviour changes. All public APIs remain importable from the
original paths (hooks.ts re-exports every hook, provider.tsx keeps all
named exports, sync.ts preserves StateSyncManager + factory).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1010 B
TypeScript
32 lines
1010 B
TypeScript
'use client'
|
|
|
|
import { useContext } from 'react'
|
|
import { ComplianceContext, type ComplianceContextValue } from './provider'
|
|
import type { SDKState, SDKAction } from '@breakpilot/compliance-sdk-types'
|
|
|
|
// =============================================================================
|
|
// MAIN HOOK
|
|
// =============================================================================
|
|
|
|
export function useCompliance(): ComplianceContextValue {
|
|
const context = useContext(ComplianceContext)
|
|
if (!context) {
|
|
throw new Error('useCompliance must be used within ComplianceProvider')
|
|
}
|
|
return context
|
|
}
|
|
|
|
// =============================================================================
|
|
// STATE HOOK
|
|
// =============================================================================
|
|
|
|
export function useComplianceState(): SDKState {
|
|
const { state } = useCompliance()
|
|
return state
|
|
}
|
|
|
|
export function useComplianceDispatch(): React.Dispatch<SDKAction> {
|
|
const { dispatch } = useCompliance()
|
|
return dispatch
|
|
}
|