'use client'; import { useState } from 'react'; import Link from 'next/link'; import { Plus, Loader2 } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { useProjects } from '@/lib/hooks/use-projects'; import { CreateProjectDialog } from '@/components/features/projects/CreateProjectDialog'; export default function ProjectsPage() { const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false); const { data: projects, isLoading, error } = useProjects(); // Log state for debugging console.log('[ProjectsPage] State:', { isLoading, error, projects, apiUrl: process.env.NEXT_PUBLIC_API_URL, }); if (isLoading) { return (
); } if (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:5000/api/v1'; console.error('[ProjectsPage] Error loading projects:', error); return (
Failed to Load Projects Unable to connect to the backend API

Error Details:

{errorMessage}

API URL:

{apiUrl}

Troubleshooting Steps:

  • Check if the backend server is running
  • Verify the API URL in .env.local
  • Check browser console (F12) for detailed errors
  • Check network tab (F12) for failed requests
); } return (

Projects

Manage your projects and track progress

{projects?.map((project) => (
{project.name} {project.key}
{project.status}

{project.description}

))} {!projects || projects.length === 0 ? (

No projects yet. Create your first project to get started.

) : null}
); }