add of projects page, and new projects
This commit is contained in:
@@ -1,38 +1,8 @@
|
||||
import React, {useEffect, useState} from "react";
|
||||
import SingleProject from "../components/SingleProject.jsx";
|
||||
import Projects from "../components/Projects.jsx";
|
||||
|
||||
function ProjectsPage() {
|
||||
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>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Voici mes projets</h1>;
|
||||
{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>
|
||||
)
|
||||
<Projects/>
|
||||
);
|
||||
}
|
||||
export default ProjectsPage;
|
||||
Reference in New Issue
Block a user