import { useState, useEffect } from 'react';
import { Link } from 'react-router-dom';
import { FolderKanban, Wrench, TrendingUp, Sparkles, ArrowRight, CheckCircle2 } from 'lucide-react';
import type { Project, Tool } from '../types';
import { getProjects, getTools } from '../api';
import ProjectCard from '../components/projects/ProjectCard';
import ToolCard from '../components/tools/ToolCard';
import ProgressBar from '../components/ui/ProgressBar';
import { useSettings } from '../hooks/useSettings';
function StatCard({ label, value, icon: Icon, sub }: { label: string; value: string | number; icon: any; sub?: string }) {
return (
);
}
export default function Dashboard() {
const { settings } = useSettings();
const [projects, setProjects] = useState([]);
const [tools, setTools] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
Promise.all([getProjects(), getTools()])
.then(([p, t]) => { setProjects(p); setTools(t); })
.finally(() => setLoading(false));
}, []);
const active = projects.filter((p) => p.status === 'active');
const complete = projects.filter((p) => p.status === 'complete');
const newTools = tools.filter((t) => t.is_new);
const avgCompletion = projects.length
? Math.round(projects.reduce((s, p) => s + p.completion, 0) / projects.length)
: 0;
const recent = [...projects].slice(0, 6);
if (loading) {
return (
);
}
return (
{/* Header */}
{settings.app_title}
High-level overview of tools and projects.
{/* Stats */}
{/* Overall progress */}
{projects.length > 0 && (
Overall Portfolio Progress
{avgCompletion}%
)}
{/* New Tools Spotlight */}
{newTools.length > 0 && (
New Tools Available
View all
{newTools.slice(0, 3).map((tool) => (
))}
)}
{/* Recent Projects */}
{recent.length === 0 ? (
No projects yet.
Create your first project →
) : (
{recent.map((project) => (
))}
)}
);
}