'use client' import Link from 'next/link' import { useEffect, useState } from 'react' interface Project { id: string name: string description: string status: string priority: string tasks: number completedTasks: number team: string[] createdAt: string } interface Task { id: string projectId: string title: string status: string priority: string assignee: string | null dueDate: string | null } interface Stats { totalProjects: number inProgress: number totalTasks: number completedTasks: number } export default function Dashboard() { const [projects, setProjects] = useState([]) const [tasks, setTasks] = useState([]) const [stats, setStats] = useState({ totalProjects: 0, inProgress: 0, totalTasks: 0, completedTasks: 0 }) const [loading, setLoading] = useState(true) useEffect(() => { Promise.all([ fetch('/api/projects').then(r => r.json()), fetch('/api/tasks').then(r => r.json()), ]).then(([projectsData, tasksData]) => { const p: Project[] = projectsData.data || [] const t: Task[] = tasksData.data || [] setProjects(p) setTasks(t) setStats({ totalProjects: p.length, inProgress: p.filter(x => x.status === 'in_progress').length, totalTasks: t.length, completedTasks: t.filter(x => x.status === 'completed').length, }) setLoading(false) }).catch(() => setLoading(false)) }, []) return (

πŸ—ΊοΈ RoadMap Dashboard

Track your projects and tasks

← Back to Home
{/* Stats */}
{loading ? (
Loading...
) : (
{/* Projects */}

Projects

{projects.length === 0 ? (

No projects yet.

) : (
    {projects.map(project => (
  • {project.name}

    {project.description}

    0 ? `${(project.completedTasks / project.tasks) * 100}%` : '0%' }} />
    {project.completedTasks}/{project.tasks}
  • ))}
)}
{/* Recent Tasks */}

Recent Tasks

{tasks.length === 0 ? (

No tasks yet.

) : (
    {tasks.slice(0, 6).map(task => (
  • {task.status === 'completed' ? 'βœ…' : task.status === 'in_progress' ? 'πŸ”„' : 'πŸ“‹'}
    {task.title}
    {task.assignee && β†’ {task.assignee}}
  • ))}
)}
)}
) } function StatCard({ label, value, icon }: { label: string; value: number; icon: string }) { return (
{icon}
{value}
{label}
) } function StatusBadge({ status }: { status: string }) { const colors: Record = { in_progress: 'bg-blue-500/30 text-blue-300', completed: 'bg-green-500/30 text-green-300', planning: 'bg-yellow-500/30 text-yellow-300', on_hold: 'bg-red-500/30 text-red-300', } return ( {status.replace('_', ' ')} ) } function PriorityBadge({ priority }: { priority: string }) { const colors: Record = { high: 'bg-red-500/30 text-red-300', medium: 'bg-yellow-500/30 text-yellow-300', low: 'bg-green-500/30 text-green-300', } return ( {priority} ) }