'use client'; import { ThumbsUp, ThumbsDown, MessageSquare, Info } from 'lucide-react'; import type { DomainScore, URTDomain } from '../types'; import { DOMAIN_COLORS, DOMAIN_LABELS } from '../types'; interface DomainScoresProps { scores: DomainScore[]; overallIndex: number | null; onDomainClick?: (domain: URTDomain) => void; activeDomain?: URTDomain | null; } // Domain descriptions explaining what each measures const DOMAIN_DESCRIPTIONS: Record = { O: 'Product/service quality, features, and reliability', P: 'Staff attitude, helpfulness, and professionalism', J: 'Are appointments on time? Is the process smooth?', E: 'Physical space, ambiance, cleanliness, and safety', A: 'Can you get there? Location, open hours, parking', V: 'Pricing fairness, value for money, and billing clarity', R: 'Trust, consistency, care, and problem recovery', }; // Get color based on score value function getScoreColor(score: number): string { if (score >= 70) return '#22c55e'; // green-500 if (score >= 50) return '#eab308'; // yellow-500 return '#ef4444'; // red-500 } // Get background color (lighter) based on score value function getScoreBgColor(score: number): string { if (score >= 70) return '#dcfce7'; // green-100 if (score >= 50) return '#fef9c3'; // yellow-100 return '#fee2e2'; // red-100 } // Get status label function getStatusLabel(score: number): string { if (score >= 70) return 'Good'; if (score >= 50) return 'Needs Work'; return 'Critical'; } // Get emoji for status function getStatusEmoji(score: number): string { if (score >= 70) return '✓'; if (score >= 50) return '!'; return '✗'; } export function DomainScores({ scores, overallIndex, onDomainClick, activeDomain, }: DomainScoresProps) { // Sort scores by domain order: O, P, J, E, A, V, R const domainOrder = ['O', 'P', 'J', 'E', 'A', 'V', 'R']; const sortedScores = [...scores].sort( (a, b) => domainOrder.indexOf(a.domain) - domainOrder.indexOf(b.domain) ); // Calculate totals const totalPositive = scores.reduce((sum, s) => sum + s.positive_count, 0); const totalNegative = scores.reduce((sum, s) => sum + s.negative_count, 0); const totalMentions = scores.reduce((sum, s) => sum + s.total_count, 0); return (
{/* Header Section */}

What Customers Talk About

How you're performing in each area of the customer experience

{/* Overall Experience Index */} {overallIndex !== null && (
Overall Score
{overallIndex.toFixed(0)} /100
)}
{/* Summary Stats */}
{totalPositive}
Happy comments
{totalNegative}
Complaints
{totalMentions}
Topics analyzed
{/* How to read this */}

Score = % positive feedback. Higher is better. Based on {totalMentions.toLocaleString()} things customers mentioned in their reviews.

{/* Domain Score Cards */}
{sortedScores.map((score) => { const isActive = activeDomain === score.domain; const scoreColor = getScoreColor(score.score); const scoreBg = getScoreBgColor(score.score); const positiveRatio = score.total_count > 0 ? Math.round((score.positive_count / score.total_count) * 100) : 0; return ( ); })}
{/* Threshold Legend */}
Click any area to filter the dashboard
<50%
50-69%
≥70%
); }