import React from 'react'; import { useStore } from '../../store/useStore'; import type { TestCaseNode } from '../../store/useStore'; import { BarChart3, PieChart, TrendingUp, CheckCircle2, XCircle, AlertCircle } from 'lucide-react'; const DashboardView: React.FC = () => { const { spaceData, currentSpaceId, testTasks, setViewMode, setSelectedTaskId, currentUser } = useStore(); const testCases = spaceData[currentSpaceId] || []; const handleOpenTask = (taskId: string) => { setSelectedTaskId(taskId); setViewMode('execution'); }; // Simple aggregation logic const getStats = (nodes: TestCaseNode[]) => { let stats = { total: 0, P0: 0, P1: 0, P2: 0, P3: 0, pass: 0, fail: 0, untested: 0 }; const traverse = (items: TestCaseNode[]) => { items.forEach(node => { stats.total++; if (node.priority) stats[node.priority]++; if (node.executionStatus === 'PASS') stats.pass++; else if (node.executionStatus === 'FAIL') stats.fail++; else stats.untested++; if (node.children) traverse(node.children); }); }; traverse(nodes); return stats; }; const stats = getStats(testCases); const passRate = stats.total > 0 ? Math.round((stats.pass / stats.total) * 100) : 0; return (