import { useState, useEffect } from 'react'; import { X, Plus, Folder, GitBranch } from 'lucide-react'; import { useLocation } from 'wouter'; import { haptics } from '@/lib/haptics'; import { supabase } from '@/lib/supabase'; import { useAuth } from '@/lib/auth'; interface Project { id: string; name: string; description: string; status: 'active' | 'completed' | 'archived'; progress: number; created_at?: string; } export default function MobileProjects() { const [, navigate] = useLocation(); const { user } = useAuth(); const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); const fetchProjects = async () => { try { if (!user) { setProjects([ { id: 'demo', name: 'Sign in to view projects', description: 'Create and manage your development projects', status: 'active', progress: 0 } ]); setLoading(false); return; } const { data, error } = await supabase .from('projects') .select('*') .eq('user_id', user.id) .order('created_at', { ascending: false }); if (error) throw error; if (data && data.length > 0) { const mapped = data.map(p => ({ id: p.id.toString(), name: p.name || 'Untitled Project', description: p.description || 'No description', status: (p.status || 'active') as 'active' | 'completed' | 'archived', progress: p.progress || 0, created_at: p.created_at })); setProjects(mapped); } else { setProjects([]); } } catch (error) { console.error('Error fetching projects:', error); } finally { setLoading(false); } }; useEffect(() => { fetchProjects(); }, [user]); const getStatusColor = (status: string) => { switch (status) { case 'active': return 'bg-emerald-900/40 border-emerald-500/40'; case 'completed': return 'bg-cyan-900/40 border-cyan-500/40'; default: return 'bg-gray-900/40 border-gray-500/40'; } }; const getProgressColor = (progress: number) => { if (progress === 100) return 'bg-cyan-500'; if (progress >= 75) return 'bg-emerald-500'; if (progress >= 50) return 'bg-yellow-500'; return 'bg-red-500'; }; return (
{/* Header */}

PROJECTS

{projects.length} items

{/* Projects List */}
{projects.map((project) => ( ))}
); }