import React, { useMemo } from 'react'; import { PieChart, Pie, Cell, Tooltip, Legend, ResponsiveContainer } from 'recharts'; import { SpotlightCard } from '../SpotlightCard'; import { InfoTooltip } from '../InfoTooltip'; const COLORS = { 'Excellent': '#10b981', // emerald-500 'Good': '#3b82f6', // blue-500 'Fair': '#eab308', // yellow-500 'Needs Repair': '#ef4444' // red-500 }; const CustomTooltip = ({ active, payload }) => { if (active && payload && payload.length) { return (

{payload[0].name}

{payload[0].value} Properties ({((payload[0].payload.percent || 0) * 100).toFixed(0)}%)

); } return null; }; export const RoofConditionChart = ({ properties }) => { const data = useMemo(() => { const counts = properties.reduce((acc, p) => { const condition = p.propertyData.roofCondition || 'Unknown'; acc[condition] = (acc[condition] || 0) + 1; return acc; }, {}); const total = properties.length; return Object.keys(counts).map(key => ({ name: key, value: counts[key], percent: counts[key] / total })); }, [properties]); return (

Roof Condition

Territory health snapshot

{/* Legend / Key - simpler than Recharts legend */}
Good
Bad
{data.map((entry, index) => ( ))} } /> {/* Center Text */}
{properties.length} Total
); };