import React, { useMemo } from 'react'; import { DomaApplication } from '../../types'; import { LayoutGrid, Building2, Inbox, AlertTriangle, ChevronRight, Users, Trash2, Pencil } from 'lucide-react'; const UNASSIGNED_MANAGER = 'Не назначен'; interface Props { title: string; subtitle?: string; applications: DomaApplication[]; onClick: () => void; type: 'district' | 'building'; buildingCount?: number; staffCount?: number; onDelete?: () => void; onViewStaff?: () => void; onEdit?: () => void; } export const PerformanceCard: React.FC = ({ title, subtitle, applications, onClick, type, buildingCount, staffCount, onDelete, onViewStaff, onEdit }) => { const stats = useMemo(() => { const now = new Date(); const active = applications.filter(a => a.status === 'new' || a.status === 'in_progress'); const overdue = active.filter(a => a.deadlineAt && new Date(a.deadlineAt) < now); const newApps = applications.filter(a => a.status === 'new'); const performance = active.length > 0 ? Math.round((1 - (overdue.length / active.length)) * 100) : 100; return { overdue, newApps, performance }; }, [applications]); const perfColor = stats.performance > 85 ? 'text-emerald-500' : stats.performance > 60 ? 'text-amber-500' : 'text-red-500'; const Icon = type === 'district' ? LayoutGrid : Building2; return (

{title}

{(subtitle != null && subtitle !== '') && (

{subtitle}

)}
{type === 'district' && (
{buildingCount} домов
)}
{stats.newApps.length} новых
{stats.overdue.length} просрочено
{type === 'district' && onViewStaff && (
{staffCount !== undefined && ( {staffCount} )}
)}

{stats.performance}%

Успеваемость

{type === 'district' && onEdit && ( )} {onDelete && ( )}
); };