"use client"; import { useState, useEffect } from "react"; import { motion } from 'framer-motion'; import { ExternalLink, Github, Calendar, ArrowLeft } from 'lucide-react'; import Link from 'next/link'; interface Project { id: number; title: string; description: string; content: string; tags: string[]; featured: boolean; category: string; date: string; github?: string; live?: string; } const ProjectsPage = () => { const [projects, setProjects] = useState([]); // Load projects from API useEffect(() => { const loadProjects = async () => { try { const response = await fetch('/api/projects?published=true'); if (response.ok) { const data = await response.json(); setProjects(data.projects || []); } else { console.error('Failed to fetch projects from API'); } } catch (error) { console.error('Error loading projects:', error); } }; loadProjects(); }, []); const categories = ["All", "Web Development", "Full-Stack", "Web Application", "Mobile App"]; const [selectedCategory, setSelectedCategory] = useState("All"); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } const filteredProjects = selectedCategory === "All" ? projects : projects.filter(project => project.category === selectedCategory); console.log('Selected category:', selectedCategory); console.log('Filtered projects:', filteredProjects); if (!mounted) { return null; } return (
{/* Header */} Back to Home

My Projects

Explore my portfolio of projects, from web applications to mobile apps. Each project showcases different skills and technologies.

{/* Category Filter */}
{categories.map((category) => ( ))}
{/* Projects Grid */}
{filteredProjects.map((project, index) => (
{project.title.split(' ').map(word => word[0]).join('').toUpperCase()}
{project.title}
{project.featured && (
Featured
)} {((project.github && project.github.trim() && project.github !== "#") || (project.live && project.live.trim() && project.live !== "#")) && (
{project.github && project.github.trim() && project.github !== "#" && ( )} {project.live && project.live.trim() && project.live !== "#" && ( )}
)}

{project.title}

{project.date}

{project.description}

{project.tags.map((tag) => ( {tag} ))}
View Project
))}
); }; export default ProjectsPage;