import { useState, useEffect } from 'react' import axios from 'axios' import './Projects.css' function ProjectCard({ project }) { return (
{project.image && (
{project.title}
)}

{project.title}

{project.description}

{project.technologies.map(tech => ( {tech} ))}
{project.githubUrl && ( GitHub Repo )} {project.liveUrl && ( Live Demo )}
) } function Projects() { const [projects, setProjects] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { const fetchProjects = async () => { try { const response = await axios.get('http://localhost:5000/api/projects') setProjects(response.data) setLoading(false) } catch (err) { console.error('Error fetching projects:', err) setError('Failed to load projects. Please try again later.') setLoading(false) } } fetchProjects() }, []) // Sort projects to show featured ones first const sortedProjects = [...projects].sort((a, b) => { if (a.featured && !b.featured) return -1 if (!a.featured && b.featured) return 1 return 0 }) if (loading) return
Loading projects...
if (error) return
{error}
return (

Projects

Here are some of the projects I've worked on. Check out my GitHub profile for more.

{sortedProjects.length === 0 ? (

No projects found.

) : ( sortedProjects.map(project => ( )) )}
) } export default Projects