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}
{equipment?.find(e => e.id === event.equipment_id)?.name}
{new Date(event.date).toLocaleDateString()}