'use client'; import { useEffect, useState } from 'react'; import { Plus, FolderKanban } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Progress } from '@/components/ui/progress'; import Link from 'next/link'; interface Project { id: string; name: string; description?: string; status: 'active' | 'paused' | 'archived'; domain: string; progress: number; task_count: number; completed_count: number; due_date?: string; } export default function ProjectsPage() { const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { fetchProjects(); }, []); async function fetchProjects() { try { const response = await fetch('/api/projects?sort=-created'); if (response.ok) { const data = await response.json(); setProjects(data.items || []); } } catch (error) { console.error('Failed to fetch projects:', error); } finally { setLoading(false); } } if (loading) { return

Loading projects...

; } const activeProjects = projects.filter((p) => p.status === 'active'); const pausedProjects = projects.filter((p) => p.status === 'paused'); const archivedProjects = projects.filter((p) => p.status === 'archived'); return (

Projects

Every outcome has a home.

{/* Active projects */} {activeProjects.length > 0 && (

Active Projects

{activeProjects.map((project) => ( ))}
)} {/* Paused projects */} {pausedProjects.length > 0 && (

Paused Projects

{pausedProjects.map((project) => ( ))}
)} {/* Archived projects */} {archivedProjects.length > 0 && (

Archived Projects

{archivedProjects.map((project) => ( ))}
)} {projects.length === 0 && ( )}
); } function ProjectCard({ project }: { project: Project }) { return (
{project.name} {project.description && (

{project.description}

)}
{project.status}
{/* Progress */}
Progress {project.progress}%
{/* Task count */}
Tasks {project.completed_count} / {project.task_count}
{/* Domain and due date */}
{project.domain} {project.due_date && ( Due: {new Date(project.due_date).toLocaleDateString()} )}
); }