From ff5344147efbc1d38f33e15eb69b587534d39cb3 Mon Sep 17 00:00:00 2001 From: Giovanni-Josserand Date: Sun, 31 Aug 2025 18:21:48 +0200 Subject: [PATCH] update of projects section to use DB --- src/components/Projects.jsx | 51 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/components/Projects.jsx b/src/components/Projects.jsx index f939bb3..70b66da 100644 --- a/src/components/Projects.jsx +++ b/src/components/Projects.jsx @@ -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
Erreur lors de la récupération des données : {error}
; } @@ -31,9 +30,9 @@ function Projects() {

Projects

- - - + {projects.map(project => ( + + ))}

-- 2.47.2