import { useState } from 'react'; import { Link } from 'react-router-dom'; import { useQuery } from '@tanstack/react-query'; import { PlusIcon, FolderIcon, EllipsisVerticalIcon, MagnifyingGlassIcon, FunnelIcon, ChartBarIcon, ClockIcon, TagIcon, Cog6ToothIcon } from '@heroicons/react/24/outline'; import { Menu, Transition } from '@headlessui/react'; import { Fragment } from 'react'; import { formatDistanceToNow } from 'date-fns'; import { projectApi } from '../../services/api'; // Project data will come from the API export default function ProjectList() { const [searchTerm, setSearchTerm] = useState(''); const [statusFilter, setStatusFilter] = useState<'all' | 'active' | 'inactive' | 'arcwhooshd'>('all'); const [bzzzFilter, setBzzzFilter] = useState<'all' | 'enabled' | 'disabled'>('all'); // Fetch real projects from API const { data: projects = [], isLoading, error } = useQuery({ queryKey: ['projects'], queryFn: async () => { return await projectApi.getProjects(); } }); const filteredProjects = projects.filter(project => { const matchesSearch = project.name.toLowerCase().includes(searchTerm.toLowerCase()) || project.description?.toLowerCase().includes(searchTerm.toLowerCase()); const matchesStatus = statusFilter === 'all' || project.status === statusFilter; const bzzzEnabled = (project as any).bzzz_config?.bzzz_enabled || false; const matchesBzzz = bzzzFilter === 'all' || (bzzzFilter === 'enabled' && bzzzEnabled) || (bzzzFilter === 'disabled' && !bzzzEnabled); return matchesSearch && matchesStatus && matchesBzzz; }); const getStatusBadge = (status: string) => { const baseClasses = 'inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium'; switch (status) { case 'active': return `${baseClasses} bg-green-100 text-green-800`; case 'inactive': return `${baseClasses} bg-gray-100 text-gray-800`; case 'arcwhooshd': return `${baseClasses} bg-red-100 text-red-800`; default: return `${baseClasses} bg-gray-100 text-gray-800`; } }; if (isLoading) { return (
{error instanceof Error ? error.message : 'Failed to load projects'}
Manage your workflow projects and track their performance
{searchTerm || statusFilter !== 'all' ? 'Try adjusting your search or filter criteria.' : 'Get started by creating your first project.' }
{project.description}
{(project as any).workflow_count || 0}
Workflows
{(project as any).file_count || 0}
Files
{(project as any).has_project_plan ? 'Yes' : 'No'}
Project Plan
{formatDistanceToNow(new Date(project.updated_at), { addSuffix: true })}
Last Update