import React from 'react'; import { Line, Pie } from 'react-chartjs-2'; import 'chart.js/auto'; function Dashboard({ equipment, maintenanceEvents }) { const stats = { total: equipment?.length || 0, active: equipment?.filter(e => e.status === 'active').length || 0, maintenance: equipment?.filter(e => e.status === 'maintenance').length || 0, repair: equipment?.filter(e => e.status === 'repair').length || 0 }; const chartData = { labels: ['Активно', 'ТО', 'Ремонт'], datasets: [{ data: [stats.active, stats.maintenance, stats.repair], backgroundColor: ['#10B981', '#F59E0B', '#EF4444'], borderWidth: 0 }] }; const chartOptions = { responsive: true, plugins: { legend: { position: 'bottom', } } }; return (

Всего оборудования

{stats.total}

Активно

{stats.active}

На ТО

{stats.maintenance}

В ремонте

{stats.repair}

Статус оборудования

Последние события

{maintenanceEvents?.slice(0, 5).map(event => (

{equipment?.find(e => e.id === event.equipment_id)?.name}

{new Date(event.date).toLocaleDateString()}

{event.status}
))}
); } export default Dashboard;