update of projects section to use DB

This commit is contained in:
Giovanni-Josserand 2025-08-31 18:21:48 +02:00
parent 91c05dae41
commit ff5344147e

View File

@ -1,29 +1,28 @@
import SingleProject from "./SingleProject.jsx";
import "../styles/Projects.css"
import React, {useEffect, useState} from "react";
function Projects() {
const codevProject = {
title: "Codev",
image: "codev",
color: "orange",
nbImage: 5,
skills: ['HTML', 'CSS', 'PHP', 'JavaScript', 'SQL'],
description: "A collaborative platform where developers can create, share, and grow coding projects. Built for solo makers or teams, it features real-time messaging and a centralized workspace."
}
const SAECProject = {
title: "SAE C++",
image: "SAE_C++",
color: "purple",
nbImage: 3,
skills: ['C++', 'Git'],
description: "A C++ program developed for creating and managing treasure hunt records, with a web interface that allows browsing and consulting the entries."
}
const proxmoxProject = {
title: "Proxmox",
image: "proxmox",
color: "green",
nbImage: 5,
skills: [],
description: "A Proxmox-based infrastructure that consolidates my personal cloud, home automation, code hosting, media services and web hosting into a single, self-hosted environment."
const [projects, setProjects] = useState([]);
const [error, setError] = useState(null);
useEffect(() => {
const fetchProjects = async () => {
try {
const response = await fetch('/api/projects');
if (!response.ok) {
throw new Error(`Erreur HTTP: ${response.status}`);
}
const data = await response.json();
setProjects(data.data);
} catch (err) {
setError(err.message);
}
};
fetchProjects();
}, []);
if (error) {
return <div>Erreur lors de la récupération des données : {error}</div>;
}
@ -31,9 +30,9 @@ function Projects() {
<section id="projects-section">
<h1 className="section-title">Projects</h1>
<div className="projects-section-list">
<SingleProject image={codevProject.image} title={codevProject.title} description={codevProject.description} skills={codevProject.skills} color={codevProject.color} nbImage={codevProject.nbImage}/>
<SingleProject image={SAECProject.image} title={SAECProject.title} description={SAECProject.description} skills={SAECProject.skills} color={SAECProject.color} nbImage={SAECProject.nbImage}/>
<SingleProject image={proxmoxProject.image} title={proxmoxProject.title} description={proxmoxProject.description} skills={proxmoxProject.skills} color={proxmoxProject.color} nbImage={proxmoxProject.nbImage}/>
{projects.map(project => (
<SingleProject image={project.image_name} title={project.title} description={project.description} skills={project.skills} color={project.color} nbImage={project.nb_image}/>
))}
</div>
<div className="show-more-container">
<p className="show-more-link">