import React, { useState, useEffect } from 'react'; import { AnalysisResult, Message } from '../types'; import { ClipboardCheck, X, CheckCircle2, AlertTriangle, Lightbulb, TrendingUp, Download, Copy, Check, FileText } from 'lucide-react'; import { Button } from './ui/button'; import { formatSessionAsMarkdown, downloadFile } from '../services/sessionStorage'; interface SessionReportProps { analysis: AnalysisResult; scenarioTitle?: string; messages?: Message[]; onExit: () => void; } const SessionReport: React.FC = ({ analysis, scenarioTitle = "CBT Roleplay Session", messages = [], onExit }) => { const [copied, setCopied] = useState(false); const handleCopyReframe = () => { navigator.clipboard.writeText(analysis.suggestions.alternativeThought); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const handleExportMarkdown = () => { const md = formatSessionAsMarkdown(scenarioTitle, analysis, messages); const fileName = `cbt-report-${scenarioTitle.toLowerCase().replace(/\s+/g, '-')}-${Date.now()}.md`; downloadFile(md, fileName, 'text/markdown'); }; const handleExportJSON = () => { const json = JSON.stringify({ scenarioTitle, analysis, messages, exportedAt: new Date().toISOString() }, null, 2); const fileName = `cbt-report-${scenarioTitle.toLowerCase().replace(/\s+/g, '-')}-${Date.now()}.json`; downloadFile(json, fileName, 'application/json'); }; return (

Session Summary Report

{scenarioTitle} • Clinical Evaluation Complete
{analysis.analysis.isAdaptive ? : } {analysis.analysis.isAdaptive ? 'Adaptive Growth Observed' : 'Clinical Patterns Detected'}
{analysis.analysis.distortions.length > 0 && (
{analysis.analysis.distortions.map(d => ( {d} ))}
)}

"{analysis.analysis.evidence}"

Mastery Level
{[1,2,3,4,5].map(s => (
))}

{analysis.rating.reason}

Master Reframe

"{analysis.suggestions.alternativeThought}"

Homework & Next Steps

{analysis.suggestions.behavioralStep}

); }; export default React.memo(SessionReport);