fix(sdk): Fix compliance scope wizard — missing labels, broken prefill, invisible helpText
- Rename `label` to `question` in profiling data (35 questions) to match ScopeProfilingQuestion type — fixes missing question headings - Sync ScopeWizardTab props with page.tsx (onEvaluate/canEvaluate/isEvaluating instead of onComplete/companyProfile/currentLevel) - Load companyProfile from SDK context instead of expecting it as prop - Auto-prefill from company profile on mount when answers are empty - Add "Aus Profil" badge for prefilled questions - Replace title-only helpText tooltip with click-to-expand visible info box - Fix ScopeQuestionBlockId to match actual block IDs in data - Add `order` field to ScopeQuestionBlock type - Fix completionStats to count against total required questions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import {
|
||||
STORAGE_KEY
|
||||
} from '@/lib/sdk/compliance-scope-types'
|
||||
import { complianceScopeEngine } from '@/lib/sdk/compliance-scope-engine'
|
||||
import { getAllQuestions } from '@/lib/sdk/compliance-scope-profiling'
|
||||
|
||||
type TabId = 'overview' | 'wizard' | 'decision' | 'export'
|
||||
|
||||
@@ -78,7 +79,7 @@ export default function ComplianceScopePage() {
|
||||
}, [scopeState, isLoading, dispatch])
|
||||
|
||||
// Handle answers change from wizard
|
||||
const handleAnswersChange = useCallback((answers: Record<string, ScopeProfilingAnswer>) => {
|
||||
const handleAnswersChange = useCallback((answers: ScopeProfilingAnswer[]) => {
|
||||
setScopeState(prev => ({
|
||||
...prev,
|
||||
answers,
|
||||
@@ -125,11 +126,11 @@ export default function ComplianceScopePage() {
|
||||
|
||||
// Calculate completion statistics
|
||||
const completionStats = useMemo(() => {
|
||||
const answers = scopeState.answers
|
||||
const totalQuestions = Object.keys(answers).length
|
||||
const answeredQuestions = Object.values(answers).filter(
|
||||
answer => answer.value !== null && answer.value !== undefined
|
||||
).length
|
||||
const allQuestions = getAllQuestions()
|
||||
const requiredQuestions = allQuestions.filter(q => q.required)
|
||||
const totalQuestions = requiredQuestions.length
|
||||
const answeredIds = new Set(scopeState.answers.map(a => a.questionId))
|
||||
const answeredQuestions = requiredQuestions.filter(q => answeredIds.has(q.id)).length
|
||||
|
||||
const completionPercentage = totalQuestions > 0
|
||||
? Math.round((answeredQuestions / totalQuestions) * 100)
|
||||
@@ -350,7 +351,7 @@ export default function ComplianceScopePage() {
|
||||
<span className="font-semibold">Active Tab:</span> {activeTab}
|
||||
</div>
|
||||
<div>
|
||||
<span className="font-semibold">Total Answers:</span> {Object.keys(scopeState.answers).length}
|
||||
<span className="font-semibold">Total Answers:</span> {scopeState.answers.length}
|
||||
</div>
|
||||
<div>
|
||||
<span className="font-semibold">Answered:</span> {completionStats.answered} ({completionStats.percentage}%)
|
||||
|
||||
Reference in New Issue
Block a user