'use client'; import React from 'react'; import { useScopedI18n } from '@/locales/client'; import { calculateSCL90Results } from '../../test/private/SCL90Calculator'; interface SCL90ResultProps { answers: string[]; } export function SCL90Result({ answers }: SCL90ResultProps) { const t = useScopedI18n('components.scl90Result'); const tCommon = useScopedI18n('common'); // Convert answer format to the format required by calculator const answersMap: { [key: number]: string } = {}; answers.forEach((answer, index) => { answersMap[index + 1] = answer; }); const results = calculateSCL90Results({ answers: answersMap, questions: [] }); const factorNames = { somatization: t('factors.somatization'), obsessive: t('factors.obsessive'), interpersonal: t('factors.interpersonal'), depression: t('factors.depression'), anxiety: t('factors.anxiety'), hostility: t('factors.hostility'), phobic: t('factors.phobic'), paranoid: t('factors.paranoid'), psychotic: t('factors.psychotic'), other: t('factors.other') }; const severityNames = { normal: tCommon('severity.normal'), mild: tCommon('severity.mild'), moderate: tCommon('severity.moderate'), severe: tCommon('severity.severe') }; const getSeverityColor = (severity: string) => { switch (severity) { case "normal": return "text-green-600"; case "mild": return "text-yellow-600"; case "moderate": return "text-orange-600"; case "severe": return "text-red-600"; default: return "text-gray-600"; } }; const getFactorSeverity = (score: number) => { if (score >= 3) return "severe"; if (score >= 2) return "moderate"; if (score >= 1.5) return "mild"; return "normal"; }; return (
{/* Overall score */}

{t('labels.overall_assessment')}

{/* Factor scores */}

{t('labels.factor_analysis')}

{Object.entries(results.factorScores).map(([factor, score]) => { const factorSeverity = getFactorSeverity(Number(score)); return (
{factorNames[factor as keyof typeof factorNames]} {severityNames[factorSeverity as keyof typeof severityNames]}
{Number(score).toFixed(2)}
); })}
{/* Result interpretation */}

{tCommon('labels.result_interpretation')}

{t('clinical.rating_criteria')}:
  • • {t('clinical.rating_scale')}
{t('clinical.judgment_criteria')}:
  • • {t('clinical.total_score_criteria')}
  • • {t('clinical.factor_score_2')}
  • • {t('clinical.factor_score_3')}
{results.isSevere && (
{t('warnings.severe_condition')}
)}
); } interface MetricCardProps { title: string; value: React.ReactNode; className?: string; } function MetricCard({ title, value, className = '' }: MetricCardProps) { return (
{title} {value}
); }