import React, { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { GripVertical, X, Users, UserPlus, UserCheck } from 'lucide-react'; import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip } from 'recharts'; import { Customer } from '../../types'; interface CustomerBreakdownWidgetProps { customers: Customer[]; isEditing?: boolean; onRemove?: () => void; } const CustomerBreakdownWidget: React.FC = ({ customers, isEditing, onRemove, }) => { const { t } = useTranslation(); const breakdownData = useMemo(() => { // Customers with lastVisit are returning, without are new const returning = customers.filter((c) => c.lastVisit !== null).length; const newCustomers = customers.filter((c) => c.lastVisit === null).length; const total = customers.length; return { new: newCustomers, returning, total, newPercentage: total > 0 ? Math.round((newCustomers / total) * 100) : 0, returningPercentage: total > 0 ? Math.round((returning / total) * 100) : 0, chartData: [ { name: 'New', value: newCustomers, color: '#8b5cf6' }, { name: 'Returning', value: returning, color: '#10b981' }, ], }; }, [customers]); return (
{isEditing && ( <>
)}

Customers This Month

{/* Pie Chart */}
{breakdownData.chartData.map((entry, index) => ( ))}
{/* Stats */}

New

{breakdownData.new}{' '} ({breakdownData.newPercentage}%)

Returning

{breakdownData.returning}{' '} ({breakdownData.returningPercentage}%)

{t('dashboard.totalCustomers')}
{breakdownData.total}
); }; export default CustomerBreakdownWidget;