import { ComplianceReport } from '../types/analysis'; import { Shield, AlertCircle, CheckCircle2, FileCheck } from 'lucide-react'; import { Progress } from './ui/progress'; import { Card } from './ui/card'; import { Badge } from './ui/badge'; interface CompliancePanelProps { report: ComplianceReport; } export function CompliancePanel({ report }: CompliancePanelProps) { const getComplianceColor = () => { if (report.cfpbAlignment >= 80) return 'text-emerald-400'; if (report.cfpbAlignment >= 60) return 'text-amber-400'; if (report.cfpbAlignment >= 45) return 'text-orange-400'; return 'text-rose-400'; }; const getComplianceBg = () => { if (report.cfpbAlignment >= 80) return 'from-emerald-500/10 via-emerald-500/5 to-transparent border-emerald-500/30'; if (report.cfpbAlignment >= 60) return 'from-amber-500/10 via-amber-500/5 to-transparent border-amber-500/30'; if (report.cfpbAlignment >= 45) return 'from-orange-500/10 via-orange-500/5 to-transparent border-orange-500/30'; return 'from-rose-500/10 via-rose-500/5 to-transparent border-rose-500/30'; }; const getComplianceStatus = () => { if (report.cfpbAlignment >= 80) return 'Compliant'; if (report.cfpbAlignment >= 60) return 'Needs Improvement'; if (report.cfpbAlignment >= 45) return 'Non-Compliant'; return 'Critically Non-Compliant'; }; const getBadgeVariantClass = () => { if (report.cfpbAlignment >= 80) return 'bg-emerald-500/10 text-emerald-400 border border-emerald-500/20'; if (report.cfpbAlignment >= 60) return 'bg-amber-500/10 text-amber-400 border border-amber-500/20'; if (report.cfpbAlignment >= 45) return 'bg-orange-500/10 text-orange-400 border border-orange-500/20'; return 'bg-rose-500/10 text-rose-400 border border-rose-500/20'; }; return (
{/* Overall Compliance Score */}

CFPB Compliance Score: {report.cfpbAlignment}%

Status: {getComplianceStatus()}

{getComplianceStatus()}

This score reflects alignment with the Consumer Financial Protection Bureau (CFPB) guidelines against deceptive practices in financial services, calculated by deducting points based on the severity of issues found.

{/* Issues Found */} {report.issues.length > 0 && (

Compliance Issues Identified

{report.issues.map((issue, index) => (
{index + 1}

{issue}

))}
)} {/* Recommendations */} {report.recommendations.length > 0 && (

Compliance Recommendations

{report.recommendations.map((recommendation, index) => (
{index + 1}

{recommendation}

))}
)} {/* CFPB Guidelines Reference */}

CFPB Guidelines Reference

Deceptive Practices (12 CFR 1041)

Prohibits unfair, deceptive, or abusive acts or practices (UDAAP) in connection with consumer financial products or services.

Truth in Lending Act (TILA)

Requires clear disclosure of key terms and costs of consumer credit, ensuring transparency in lending practices.

Electronic Fund Transfer Act (EFTA)

Protects consumers engaging in electronic fund transfers, requiring clear disclosure of terms and conditions.

Fair Debt Collection Practices Act

Prohibits abusive, unfair, or deceptive practices by debt collectors, including manipulative communication tactics.

{/* Action Items */}

📋 Compliance Action Items

  1. Address critical violations immediately to avoid regulatory action
  2. Implement recommended design changes in order of severity
  3. Conduct user testing to validate improved experience
  4. Schedule follow-up compliance audit after changes are made
  5. Document all changes for regulatory review
  6. Train design and product teams on ethical UI principles
{/* AI Explanation */}

🤖 XAI Compliance Analysis

Our compliance engine uses natural language processing to match detected dark patterns against CFPB regulation text. Each violation is cross-referenced with specific guideline sections to provide actionable, legally-grounded recommendations. The compliance score is calculated using a weighted severity model that prioritizes consumer protection.

); }