import React from 'react'; import { useDocument } from '../contexts/DocumentContext'; interface DocumentPreviewProps { showTitle?: boolean; compact?: boolean; className?: string; } const DocumentPreview: React.FC = ({ showTitle = true, compact = false, className = '' }) => { const { documentState } = useDocument(); const { clientInformation, benefitConfiguration, reviewData, generatedDocuments, currentStep, deductibleDetails, outOfPocketDetails, mentalHealthBenefits, inpatientBenefits, outpatientBenefits, claimsSpecialHandling, otherBenefits, msagRecords, dxSupplementalRecords } = documentState; const formatDate = (dateString: string) => { if (!dateString) return 'Not specified'; try { return new Date(dateString).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); } catch { return dateString; } }; // Helper function to format arrays safely const formatArray = (arr: string[] | undefined | null) => { if (!Array.isArray(arr)) return 'None'; const filtered = arr.filter(item => item && item.trim() !== ''); return filtered.length > 0 ? filtered.join(', ') : 'None'; }; // Helper function to safely format values const formatValue = (value: any) => { if (value === null || value === undefined || value === '') return 'Not specified'; if (typeof value === 'boolean') return value ? 'Yes' : 'No'; return String(value); }; // Helper to check if section has meaningful data const hasData = (obj: any): boolean => { if (!obj) return false; if (typeof obj === 'object') { return Object.values(obj).some((value: any): boolean => { if (Array.isArray(value)) return value.length > 0; if (typeof value === 'object' && value !== null) return hasData(value); return value !== null && value !== undefined && value !== ''; }); } return obj !== null && obj !== undefined && obj !== ''; }; const previewStyles = { container: { background: 'linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%)', borderRadius: compact ? '12px' : '20px', boxShadow: '0 20px 60px rgba(0, 0, 0, 0.08), 0 8px 25px rgba(0, 0, 0, 0.05)', border: '1px solid #e2e8f0', fontFamily: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', maxHeight: compact ? '500px' : 'none', overflow: compact ? 'auto' : 'visible' } as React.CSSProperties, header: { background: 'linear-gradient(135deg, #4338ca 0%, #6366f1 50%, #8b5cf6 100%)', color: 'white', padding: compact ? '20px 24px' : '32px 40px', borderRadius: `${compact ? '12px' : '20px'} ${compact ? '12px' : '20px'} 0 0`, position: 'relative', overflow: 'hidden' } as React.CSSProperties, headerPattern: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, backgroundImage: ` radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.15) 0%, transparent 50%), radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%), radial-gradient(circle at 40% 60%, rgba(255, 255, 255, 0.08) 0%, transparent 50%) `, pointerEvents: 'none' } as React.CSSProperties, headerContent: { position: 'relative', zIndex: 1 } as React.CSSProperties, title: { fontSize: compact ? '1.6rem' : '2.2rem', fontWeight: '700', margin: 0, textShadow: '0 4px 15px rgba(0, 0, 0, 0.2)', letterSpacing: '-0.025em' } as React.CSSProperties, subtitle: { fontSize: compact ? '1rem' : '1.1rem', opacity: 0.9, margin: '8px 0 0 0', fontWeight: '400' } as React.CSSProperties, content: { padding: compact ? '20px 24px' : '40px', lineHeight: '1.6', background: 'white' } as React.CSSProperties, section: { marginBottom: compact ? '24px' : '32px', paddingBottom: compact ? '20px' : '24px', borderBottom: '2px solid #f1f5f9', background: 'white', borderRadius: '12px', padding: compact ? '16px 20px' : '24px 28px', boxShadow: '0 2px 8px rgba(0, 0, 0, 0.04)' } as React.CSSProperties, sectionTitle: { fontSize: compact ? '1.2rem' : '1.4rem', fontWeight: '700', color: '#1e293b', marginBottom: compact ? '16px' : '20px', display: 'flex', alignItems: 'center', gap: '12px', borderBottom: '2px solid #e2e8f0', paddingBottom: '8px' } as React.CSSProperties, fieldGrid: { display: 'grid', gridTemplateColumns: compact ? '1fr' : 'repeat(auto-fit, minmax(280px, 1fr))', gap: compact ? '12px' : '16px', marginBottom: '16px' } as React.CSSProperties, field: { padding: compact ? '12px 16px' : '16px 20px', background: 'linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%)', borderRadius: '10px', border: '1px solid #e2e8f0', transition: 'all 0.2s ease' } as React.CSSProperties, fieldLabel: { fontSize: compact ? '0.85rem' : '0.95rem', fontWeight: '700', color: '#475569', marginBottom: '6px', textTransform: 'uppercase' as const, letterSpacing: '0.05em' } as React.CSSProperties, fieldValue: { fontSize: compact ? '0.95rem' : '1.05rem', color: '#1e293b', fontWeight: '500', lineHeight: '1.5' } as React.CSSProperties, emptyState: { color: '#94a3b8', fontStyle: 'italic', fontSize: compact ? '0.9rem' : '1rem', padding: '24px', textAlign: 'center' as const, background: '#f8fafc', borderRadius: '8px', border: '2px dashed #cbd5e1' } as React.CSSProperties, statusBadge: { display: 'inline-flex', alignItems: 'center', padding: '6px 16px', borderRadius: '25px', fontSize: '0.8rem', fontWeight: '700', textTransform: 'uppercase' as const, letterSpacing: '0.5px', boxShadow: '0 2px 6px rgba(0, 0, 0, 0.1)' } as React.CSSProperties, listItem: { padding: compact ? '8px 14px' : '10px 18px', background: 'linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 100%)', border: '1px solid #a78bfa', borderRadius: '8px', margin: '6px 4px', fontSize: compact ? '0.85rem' : '0.9rem', fontWeight: '600', color: '#581c87', display: 'inline-block', boxShadow: '0 2px 4px rgba(139, 92, 246, 0.1)' } as React.CSSProperties, detailCard: { background: 'white', border: '1px solid #e2e8f0', borderRadius: '8px', padding: '16px', margin: '8px 0', boxShadow: '0 1px 3px rgba(0, 0, 0, 0.05)' } as React.CSSProperties, metricCard: { background: 'linear-gradient(135deg, #fef3c7 0%, #fde68a 100%)', border: '1px solid #f59e0b', borderRadius: '12px', padding: '16px 20px', textAlign: 'center' as const, boxShadow: '0 4px 12px rgba(245, 158, 11, 0.15)' } as React.CSSProperties, metricValue: { fontSize: '1.8rem', fontWeight: '800', color: '#92400e', display: 'block' } as React.CSSProperties, metricLabel: { fontSize: '0.9rem', fontWeight: '600', color: '#78350f', textTransform: 'uppercase' as const, letterSpacing: '0.05em' } as React.CSSProperties }; const getStatusBadgeStyle = (status: string) => { const baseStyle = previewStyles.statusBadge; switch (status) { case 'completed': return { ...baseStyle, background: 'linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%)', color: '#166534' }; case 'processing': return { ...baseStyle, background: 'linear-gradient(135deg, #fef3c7 0%, #fde68a 100%)', color: '#92400e' }; case 'error': return { ...baseStyle, background: 'linear-gradient(135deg, #fee2e2 0%, #fecaca 100%)', color: '#991b1b' }; default: return { ...baseStyle, background: 'linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%)', color: '#374151' }; } }; // Calculate completion metrics const getCompletionMetrics = () => { const totalSections = 7; let completedSections = 0; let totalFields = 0; let completedFields = 0; // Client Information if (clientInformation.clientName) { completedSections++; totalFields += 6; if (clientInformation.clientName) completedFields++; if (clientInformation.clientType) completedFields++; if (clientInformation.lineOfBusiness) completedFields++; if (clientInformation.effectiveDate) completedFields++; if (clientInformation.termDate) completedFields++; if (clientInformation.exportTargets.length > 0) completedFields++; } // Add other sections to metrics if (deductibleDetails?.appliesForBenefit || outOfPocketDetails?.appliesForBenefit) completedSections++; if (mentalHealthBenefits && hasData(mentalHealthBenefits)) completedSections++; if (inpatientBenefits && hasData(inpatientBenefits)) completedSections++; if (outpatientBenefits && hasData(outpatientBenefits)) completedSections++; if (claimsSpecialHandling && hasData(claimsSpecialHandling)) completedSections++; if (otherBenefits && hasData(otherBenefits)) completedSections++; return { completedSections, totalSections, completedFields, totalFields: Math.max(totalFields, 1), sectionProgress: (completedSections / totalSections) * 100, fieldProgress: totalFields > 0 ? (completedFields / totalFields) * 100 : 0 }; }; const metrics = getCompletionMetrics(); return (
{/* Enhanced Header */}
{showTitle && ( <>

📋 Document Configuration Preview

Step {currentStep} of 7 • {clientInformation.clientName || 'New Benefit Document'}

📊 {Math.round(metrics.sectionProgress)}% Complete
📝 {metrics.completedFields} of {metrics.totalFields} fields
🗂️ {metrics.completedSections} of {metrics.totalSections} sections
)}
{/* Quick Overview Metrics */}
{currentStep} Current Step
{metrics.completedSections} Completed Sections
{generatedDocuments.length} Generated Documents
{(msagRecords?.length || 0) + (dxSupplementalRecords?.length || 0)} Data Records
{/* Client Information Section */}

🏢 Client Information & Setup

{clientInformation.clientName ? ( <>
Client Name
{clientInformation.clientName}
Client Type
{formatValue(clientInformation.clientType)}
Line of Business
{formatValue(clientInformation.lineOfBusiness)}
{clientInformation.parentCode && (
Parent Code
{clientInformation.parentCode}
)}
Effective Date
{formatDate(clientInformation.effectiveDate)}
Term Date
{formatDate(clientInformation.termDate)}
{/* Export Targets */} {clientInformation.exportTargets && clientInformation.exportTargets.length > 0 && (
Export Targets ({clientInformation.exportTargets.length})
{clientInformation.exportTargets.map((target, index) => ( 📤 {target} ))}
)} {/* Approver Emails */} {clientInformation.approverEmails && clientInformation.approverEmails.some(email => email.trim() !== '') && (
Approver Emails ({clientInformation.approverEmails.filter(email => email.trim() !== '').length})
{clientInformation.approverEmails .filter(email => email.trim() !== '') .map((email, index) => (
📧 {email}
))}
)} ) : (
⚠️ No client information provided yet. Please complete Step 1 to see preview data.
)}
{/* Financial Maximums Section */} {(deductibleDetails?.appliesForBenefit || outOfPocketDetails?.appliesForBenefit) && (

💰 Financial Maximums & Deductibles

{deductibleDetails?.appliesForBenefit && (
Deductible Configuration
{deductibleDetails.inNetwork?.enabled && "✅ In-Network Enabled"} {deductibleDetails.inNetwork?.enabled && deductibleDetails.outOfNetwork?.enabled && " • "} {deductibleDetails.outOfNetwork?.enabled && "✅ Out-of-Network Enabled"}
{deductibleDetails.inNetwork?.enabled && (
In-Network Details: {deductibleDetails.inNetwork.appliesTo && (
Applies to: {formatArray(deductibleDetails.inNetwork.appliesTo)}
)} {deductibleDetails.inNetwork.embeddedBenefit && (
Individual: {formatValue(deductibleDetails.inNetwork.embeddedBenefit.individual)} • Family: {formatValue(deductibleDetails.inNetwork.embeddedBenefit.family)}
)}
)}
)} {outOfPocketDetails?.appliesForBenefit && (
Out-of-Pocket Maximums
{outOfPocketDetails.inNetwork?.enabled && "✅ In-Network Enabled"} {outOfPocketDetails.inNetwork?.enabled && outOfPocketDetails.outOfNetwork?.enabled && " • "} {outOfPocketDetails.outOfNetwork?.enabled && "✅ Out-of-Network Enabled"}
)}
)} {/* Mental Health Benefits Section */} {mentalHealthBenefits && hasData(mentalHealthBenefits) && (

🧠 Mental Health & Substance Abuse Benefits

{mentalHealthBenefits.eap?.covered && (
Employee Assistance Program (EAP)
✅ Covered • Visit Limit: {formatValue(mentalHealthBenefits.eap.visitLimit)} {mentalHealthBenefits.eap.limits && (
Limits: {mentalHealthBenefits.eap.limits}
)}
)} {mentalHealthBenefits.outpatientTherapies?.rows && mentalHealthBenefits.outpatientTherapies.rows.length > 0 && (
Outpatient Therapy Services ({mentalHealthBenefits.outpatientTherapies.rows.length} configured)
{mentalHealthBenefits.outpatientTherapies.rows.slice(0, compact ? 2 : 4).map((row, index) => (
In-Network:
Covered: {formatValue(row.inNetwork.coveredOrRtm)}
Auth Required: {formatValue(row.inNetwork.authRequirement)}
{row.inNetwork.maxVisit &&
Max Visits: {row.inNetwork.maxVisit}
}
Out-of-Network:
Covered: {formatValue(row.outOfNetwork.coveredOrRtm)}
Auth Required: {formatValue(row.outOfNetwork.authRequirement)}
{row.outOfNetwork.maxVisit &&
Max Visits: {row.outOfNetwork.maxVisit}
}
))} {mentalHealthBenefits.outpatientTherapies.rows.length > (compact ? 2 : 4) && (
+{mentalHealthBenefits.outpatientTherapies.rows.length - (compact ? 2 : 4)} more therapy configurations...
)}
)}
)} {/* Inpatient Benefits Section */} {inpatientBenefits && hasData(inpatientBenefits) && (

🏨 Inpatient Benefits

{inpatientBenefits.selectedOptions && inpatientBenefits.selectedOptions.length > 0 && (
Selected Benefit Categories ({inpatientBenefits.selectedOptions.length})
{inpatientBenefits.selectedOptions.map((option, index) => ( {option.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase())} ))}
)} {/* Pre-Certification Penalty Details */} {inpatientBenefits.preCertPenalty && (
Pre-Certification Penalty Configuration
In-Network:
Applies: {inpatientBenefits.preCertPenalty.inNetwork.applies ? '✅ Yes' : '❌ No'}
{inpatientBenefits.preCertPenalty.inNetwork.applies && (
Definition: {formatValue(inpatientBenefits.preCertPenalty.inNetwork.definePenalty)}
)}
Out-of-Network:
Applies: {inpatientBenefits.preCertPenalty.outNetwork.applies ? '✅ Yes' : '❌ No'}
{inpatientBenefits.preCertPenalty.outNetwork.applies && (
Definition: {formatValue(inpatientBenefits.preCertPenalty.outNetwork.definePenalty)}
)}
)} {/* Facility Services */} {inpatientBenefits.facilityRows && inpatientBenefits.facilityRows.length > 0 && (
Facility Services Configuration ({inpatientBenefits.facilityRows.length} services)
{inpatientBenefits.facilityRows.slice(0, compact ? 2 : 6).map((row, index) => (
Service: {formatValue(row.service)} • Network: {row.networkType === 'in' ? 'In-Network' : 'Out-of-Network'}
Coverage: {formatValue(row.coveredOrRTM)}
Psych/SA: {formatValue(row.psychOrSA)}
Auth Required: {formatValue(row.authRequirement)}
Copay: {formatValue(row.copay)}
Coinsurance: {formatValue(row.coinsurance)}
{row.exceptions && (
Exceptions: {row.exceptions}
)}
))} {inpatientBenefits.facilityRows.length > (compact ? 2 : 6) && (
+{inpatientBenefits.facilityRows.length - (compact ? 2 : 6)} more facility service configurations...
)}
)} {/* Professional Services */} {inpatientBenefits.professionalRows && inpatientBenefits.professionalRows.length > 0 && (
Professional Services Configuration ({inpatientBenefits.professionalRows.length} services)
{inpatientBenefits.professionalRows.slice(0, compact ? 2 : 4).map((row, index) => (
Service: {formatValue(row.service)} • Network: {row.networkType === 'in' ? 'In-Network' : 'Out-of-Network'}
Coverage: {formatValue(row.coveredOrRTM)}
Psych/SA: {formatValue(row.psychOrSA)}
Auth Required: {formatValue(row.authRequirement)}
Copay: {formatValue(row.copay)}
Coinsurance: {formatValue(row.coinsurance)}
{row.exceptions && (
Exceptions: {row.exceptions}
)}
))} {inpatientBenefits.professionalRows.length > (compact ? 2 : 4) && (
+{inpatientBenefits.professionalRows.length - (compact ? 2 : 4)} more professional service configurations...
)}
)} {/* Alternative Care Services */} {inpatientBenefits.alternativeCareRows && inpatientBenefits.alternativeCareRows.length > 0 && (
Alternative Care Services ({inpatientBenefits.alternativeCareRows.length} services)
{inpatientBenefits.alternativeCareRows.slice(0, compact ? 2 : 3).map((row, index) => (
Service: {formatValue(row.service)} • Network: {row.networkType === 'in' ? 'In-Network' : 'Out-of-Network'}
Coverage: {formatValue(row.coveredOrRTM)}
Psych/SA: {formatValue(row.psychOrSA)}
Auth Required: {formatValue(row.authRequirement)}
Copay: {formatValue(row.copay)}
Coinsurance: {formatValue(row.coinsurance)}
{row.exceptions && (
Exceptions: {row.exceptions}
)}
))} {inpatientBenefits.alternativeCareRows.length > (compact ? 2 : 3) && (
+{inpatientBenefits.alternativeCareRows.length - (compact ? 2 : 3)} more alternative care configurations...
)}
)}
)} {/* Outpatient Benefits Section */} {outpatientBenefits && hasData(outpatientBenefits) && (

🏥 Outpatient Benefits

{outpatientBenefits.selectedOptions && outpatientBenefits.selectedOptions.length > 0 && (
Selected Benefit Categories ({outpatientBenefits.selectedOptions.length})
{outpatientBenefits.selectedOptions.map((option, index) => ( {option.toUpperCase()} ))}
)} {/* EAP Configuration */} {outpatientBenefits.eapConfig?.covered && (
Employee Assistance Program (EAP) Configuration
✅ Covered • Visit Limit: {formatValue(outpatientBenefits.eapConfig.visitLimit)} {outpatientBenefits.eapConfig.limits && (
Additional Limits: {outpatientBenefits.eapConfig.limits}
)} {outpatientBenefits.eapConfig.exceptions && (
Exceptions: {outpatientBenefits.eapConfig.exceptions}
)}
)} {/* ABA Configuration */} {(outpatientBenefits.abaConfig?.inNetwork.covered || outpatientBenefits.abaConfig?.outNetwork.covered) && (
Applied Behavior Analysis (ABA) Configuration
In-Network:
Covered: {outpatientBenefits.abaConfig?.inNetwork.covered ? '✅ Yes' : '❌ No'}
Auth Required: {outpatientBenefits.abaConfig?.inNetwork.authRequired ? '✅ Yes' : '❌ No'}
{outpatientBenefits.abaConfig?.inNetwork.exceptions && (
Exceptions: {outpatientBenefits.abaConfig.inNetwork.exceptions}
)}
Out-of-Network:
Covered: {outpatientBenefits.abaConfig?.outNetwork.covered ? '✅ Yes' : '❌ No'}
Auth Required: {outpatientBenefits.abaConfig?.outNetwork.authRequired ? '✅ Yes' : '❌ No'}
{outpatientBenefits.abaConfig?.outNetwork.exceptions && (
Exceptions: {outpatientBenefits.abaConfig.outNetwork.exceptions}
)}
)} {/* Therapy Services */} {outpatientBenefits.therapyRows && outpatientBenefits.therapyRows.length > 0 && (
Therapy Services Configuration ({outpatientBenefits.therapyRows.length} services)
{outpatientBenefits.therapyRows.slice(0, compact ? 2 : 5).map((row, index) => (
Service: {formatValue(row.service)} • Network: {row.networkType === 'in' ? 'In-Network' : 'Out-of-Network'}
Coverage: {formatValue(row.covered)}
Psych/SA: {formatValue(row.psychOrSA)}
Auth Required: {formatValue(row.authRequirement)}
{row.exceptions && (
Exceptions: {row.exceptions}
)}
))} {outpatientBenefits.therapyRows.length > (compact ? 2 : 5) && (
+{outpatientBenefits.therapyRows.length - (compact ? 2 : 5)} more therapy service configurations...
)}
)} {/* Benefit Configurations */} {((outpatientBenefits.inNetworkConfig?.length || 0) + (outpatientBenefits.outNetworkConfig?.length || 0)) > 0 && (
Additional Benefit Configurations
{outpatientBenefits.inNetworkConfig && outpatientBenefits.inNetworkConfig.length > 0 && (
In-Network Configurations ({outpatientBenefits.inNetworkConfig.length}): {outpatientBenefits.inNetworkConfig.slice(0, 3).map((config, index) => (
• {typeof config === 'string' ? config : JSON.stringify(config).substring(0, 50) + '...'}
))} {outpatientBenefits.inNetworkConfig.length > 3 && (
+{outpatientBenefits.inNetworkConfig.length - 3} more...
)}
)} {outpatientBenefits.outNetworkConfig && outpatientBenefits.outNetworkConfig.length > 0 && (
Out-of-Network Configurations ({outpatientBenefits.outNetworkConfig.length}): {outpatientBenefits.outNetworkConfig.slice(0, 3).map((config, index) => (
• {typeof config === 'string' ? config : JSON.stringify(config).substring(0, 50) + '...'}
))} {outpatientBenefits.outNetworkConfig.length > 3 && (
+{outpatientBenefits.outNetworkConfig.length - 3} more...
)}
)}
)}
)} {/* Claims Special Handling Section */} {claimsSpecialHandling && hasData(claimsSpecialHandling) && (

📋 Claims Special Handling

{/* Coversheeted Information */} {claimsSpecialHandling.coversheeted?.carrier && (
Coversheeted Claims Information
Carrier: {claimsSpecialHandling.coversheeted.carrier} {claimsSpecialHandling.coversheeted.customerServicePhone && (
Customer Service Phone: {claimsSpecialHandling.coversheeted.customerServicePhone}
)}
)} {/* Comments */} {claimsSpecialHandling.comments && (
Special Handling Comments
{claimsSpecialHandling.comments}
)} {/* Break in Treatment */} {claimsSpecialHandling.breakInTreatment && (
Break in Treatment Definition
{claimsSpecialHandling.breakInTreatment}
)} {/* Special Requirements */} {(claimsSpecialHandling.expatriatesCovered || claimsSpecialHandling.medicareAuthRequired) && (
Special Requirements & Flags
{claimsSpecialHandling.expatriatesCovered && (
Expatriates Coverage: {claimsSpecialHandling.expatriatesCovered.toUpperCase()}
)} {claimsSpecialHandling.medicareAuthRequired && (
Medicare Auth Required: {claimsSpecialHandling.medicareAuthRequired.toUpperCase()}
)}
)} {/* Additional Information */} {claimsSpecialHandling.miscellaneous && (
Miscellaneous Information
{claimsSpecialHandling.miscellaneous}
)}
)} {/* Other Benefits Section */} {otherBenefits && hasData(otherBenefits) && (

🔧 Other Benefits & Special Services

{otherBenefits.selectedOptions && otherBenefits.selectedOptions.length > 0 && (
Selected Other Benefit Types ({otherBenefits.selectedOptions.length})
{otherBenefits.selectedOptions.map((option, index) => ( {option.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase())} ))}
)} {/* Emergency Services */} {otherBenefits.emergencyRows && otherBenefits.emergencyRows.length > 0 && (
Emergency Services ({otherBenefits.emergencyRows.length} configurations)
{otherBenefits.emergencyRows.slice(0, compact ? 2 : 4).map((row, index) => (
Service: {formatValue(row.service)} • Network: {row.networkType === 'in' ? 'In-Network' : 'Out-of-Network'}
Coverage: {formatValue(row.coveredOrRTM)}
Auth Required: {formatValue(row.authRequirement)}
Copay: {formatValue(row.copay)}
Coinsurance: {formatValue(row.coinsurance)}
))} {otherBenefits.emergencyRows.length > (compact ? 2 : 4) && (
+{otherBenefits.emergencyRows.length - (compact ? 2 : 4)} more emergency service configurations...
)}
)} {/* ECT Services */} {otherBenefits.ectRows && otherBenefits.ectRows.length > 0 && (
Electroconvulsive Therapy (ECT) Services ({otherBenefits.ectRows.length} configurations)
{otherBenefits.ectRows.slice(0, compact ? 1 : 3).map((row, index) => (
Service: {formatValue(row.service)} • Network: {row.networkType === 'in' ? 'In-Network' : 'Out-of-Network'}
Coverage: {formatValue(row.coveredOrRTM)}
Auth Required: {formatValue(row.authRequirement)}
Copay: {formatValue(row.copay)}
Coinsurance: {formatValue(row.coinsurance)}
))} {otherBenefits.ectRows.length > (compact ? 1 : 3) && (
+{otherBenefits.ectRows.length - (compact ? 1 : 3)} more ECT configurations...
)}
)} {/* Out of Country Benefits */} {otherBenefits.outOfCountry?.coveredBenefit && (
Out-of-Country Benefits
Coverage Status: ✅ Covered
Emergency Only: {otherBenefits.outOfCountry.emergencyServicesOnly ? '✅ Yes' : '❌ No'}
Payment to Member: {otherBenefits.outOfCountry.paymentToMember ? '✅ Yes' : '❌ No'}
Claim Paid at INN: {otherBenefits.outOfCountry.claimPaidAtINN ? '✅ Yes' : '❌ No'}
)} {/* Transition Benefits */} {otherBenefits.transitionBenefitsConfig?.coveredBenefit && (
Transition Benefits Configuration
Applies to Types:
{formatArray(otherBenefits.transitionBenefitsConfig.appliesTo.type)}
Applies to Settings:
{formatArray(otherBenefits.transitionBenefitsConfig.appliesTo.setting)}
Auth Required: {formatValue(otherBenefits.transitionBenefitsConfig.authRequired)}
Start Date: {formatValue(otherBenefits.transitionBenefitsConfig.startDate)} • End Date: {formatValue(otherBenefits.transitionBenefitsConfig.endDate)}
{otherBenefits.transitionBenefitsConfig.exceptions && (
Exceptions: {otherBenefits.transitionBenefitsConfig.exceptions}
)}
)} {/* Other Services Summary */} {((otherBenefits.otherOutpatientRows?.length || 0) + (otherBenefits.otherServicesRows?.length || 0)) > 0 && (
Additional Services Summary
Other Outpatient Services:
{otherBenefits.otherOutpatientRows?.length || 0} configurations
Other Services:
{otherBenefits.otherServicesRows?.length || 0} configurations
)}
)} {/* Benefit Configuration Summary */}

🏥 Comprehensive Benefit Configuration Summary

{benefitConfiguration.benefitTypes.length > 0 ? ( <>
Primary Benefit Types ({benefitConfiguration.benefitTypes.length})
{benefitConfiguration.benefitTypes.map((type, index) => ( {type} ))}
{Object.keys(benefitConfiguration.coverageDetails).length > 0 && (
Detailed Coverage Configurations ({Object.keys(benefitConfiguration.coverageDetails).length} items)
{Object.entries(benefitConfiguration.coverageDetails).slice(0, compact ? 3 : 8).map(([key, value], index) => (
{key.replace(/([A-Z])/g, ' $1').replace(/^./, str => str.toUpperCase())}
{typeof value === 'object' ? (
{JSON.stringify(value, null, 2).substring(0, 200)} {JSON.stringify(value).length > 200 && '...'}
) : ( formatValue(value) )}
))} {Object.keys(benefitConfiguration.coverageDetails).length > (compact ? 3 : 8) && (
+{Object.keys(benefitConfiguration.coverageDetails).length - (compact ? 3 : 8)} more coverage detail configurations...
)}
)} ) : (
No benefit configuration set up yet. Complete Steps 2-6 to configure comprehensive benefit details.
)}
{/* Data Records Section */} {((msagRecords && msagRecords.length > 0) || (dxSupplementalRecords && dxSupplementalRecords.length > 0)) && (

📊 Configuration Data Records

{msagRecords && msagRecords.length > 0 && (
MSAG Records ({msagRecords.length})
Service authorization and billing configurations defined
Latest: {msagRecords[0]?.serviceType || 'Unknown'} • Auth Class: {msagRecords[0]?.authClass || 'Not specified'}
)} {dxSupplementalRecords && dxSupplementalRecords.length > 0 && (
Diagnosis Supplemental Records ({dxSupplementalRecords.length})
Diagnosis-specific coverage rules defined
)}
)} {/* Enhanced Progress Summary */}

📊 Configuration Progress & Summary

Current Progress
Step {currentStep} of 7 ({Math.round((currentStep / 7) * 100)}% Complete)
Document Status
{clientInformation.clientName ? ( ✅ Configuration in Progress ) : ( ⚠️ Not Started )}
Last updated: {new Date().toLocaleDateString()}
{/* Quick Actions */} {currentStep < 7 && (
🚀 Next Steps
Continue with Step {currentStep + 1} to complete the benefit configuration
)}
); }; export default DocumentPreview;