update of experiences section to use DB #18
@ -1,39 +1,45 @@
|
|||||||
import '../styles/Experiences.css';
|
import '../styles/Experiences.css';
|
||||||
import SingleExperience from './SingleExperience';
|
import SingleExperience from './SingleExperience';
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
|
|
||||||
function Experiences() {
|
function Experiences() {
|
||||||
const experiencesData = [
|
const [experiences, setExperiences] = useState([]);
|
||||||
{
|
const [experienceTasks, setExperienceTasks] = useState([]);
|
||||||
role: "Web Development Intern",
|
const [error, setError] = useState(null);
|
||||||
company: "Pandora",
|
|
||||||
duration: "April 2024",
|
useEffect(() => {
|
||||||
location: "Rennes (Ille-et-Vilaine), France",
|
const fetchExperiencesAndTasks = async () => {
|
||||||
tasks: [
|
try {
|
||||||
"Development of a dynamic website with database integration (HTML, CSS, PHP, SQL)",
|
let response = await fetch('/api/experiences');
|
||||||
"Created a reusable interface used as an internal learning resource",
|
if (!response.ok) {
|
||||||
"Introduction to GitHub Actions"
|
throw new Error(`Erreur HTTP: ${response.status}`);
|
||||||
]
|
}
|
||||||
},
|
let data = await response.json();
|
||||||
{
|
setExperiences(data.data);
|
||||||
role: "IT Support Intern",
|
|
||||||
company: "INRAE",
|
response = await fetch('/api/experienceTasks');
|
||||||
duration: "April 2023",
|
if (!response.ok) {
|
||||||
location: "Rennes (Ille-et-Vilaine), France",
|
throw new Error(`Erreur HTTP: ${response.status}`);
|
||||||
tasks: [
|
}
|
||||||
"Introduction to ProxMox Backup and UpdateEngine tools",
|
data = await response.json();
|
||||||
"Preparation of two workstations",
|
setExperienceTasks(data.data);
|
||||||
"Setup of a Wi-Fi hotspot using a Raspberry Pi",
|
} catch (err) {
|
||||||
"Installation of a RAID 1 system"
|
setError(err.message);
|
||||||
]
|
}
|
||||||
|
};
|
||||||
|
fetchExperiencesAndTasks();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return <div>Erreur lors de la récupération des données : {error}</div>;
|
||||||
}
|
}
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section id="experiences-section">
|
<section id="experiences-section">
|
||||||
<h1 className="section-title">Experiences</h1>
|
<h1 className="section-title">Experiences</h1>
|
||||||
<div className="experiences-container">
|
<div className="experiences-container">
|
||||||
{experiencesData.map((exp) => (
|
{experiences.map((exp) => (
|
||||||
<SingleExperience experience={exp}/>
|
<SingleExperience experience={exp} tasks={experienceTasks.filter(task => task.experience_id === exp.id)}/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import '../styles/SingleExperience.css';
|
import '../styles/SingleExperience.css';
|
||||||
|
|
||||||
function SingleExperience({ experience }) {
|
function SingleExperience({ experience, tasks }) {
|
||||||
return (
|
return (
|
||||||
<div className="experience-card">
|
<div className="experience-card">
|
||||||
<div className="experience-card-left">
|
<div className="experience-card-left">
|
||||||
@ -11,8 +11,8 @@ function SingleExperience({ experience }) {
|
|||||||
<div className="experience-card-right">
|
<div className="experience-card-right">
|
||||||
<h3 className="experience-role">{experience.role}</h3>
|
<h3 className="experience-role">{experience.role}</h3>
|
||||||
<ul className="experience-tasks">
|
<ul className="experience-tasks">
|
||||||
{experience.tasks.map((task, index) => (
|
{tasks.map((task) => (
|
||||||
<li key={index}>{task}</li>
|
<li>{task.description}</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -7,7 +7,7 @@ function Skills() {
|
|||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchProjects = async () => {
|
const fetchSkills = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/skills');
|
const response = await fetch('/api/skills');
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@ -19,7 +19,7 @@ function Skills() {
|
|||||||
setError(err.message);
|
setError(err.message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchProjects();
|
fetchSkills();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user