"use client"; import React, { useState, useEffect } from "react"; import Image from "next/image"; const Educations = () => { const [formationsData, setFormationsData] = useState(null); useEffect(() => { const fetchFormations = async () => { try { const response = await fetch("/assets/data/data.json"); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); setFormationsData(Object.values(data.formations).reverse()); } catch (error) { console.error("Failed to fetch formations data:", error); } }; fetchFormations(); }, []); if (!formationsData) { return (

Loading Educations...

); } return (

Educations

{/* Formations container */}
{formationsData.map((formation, index) => (
{/* Conditional rendering for alternating layout */} {index % 2 === 0 ? ( <> {/* Left/Image Column */}
{`${formation.name}
{/* Right/Content Column */}

{formation.name}

{/* Use whitespace-pre-wrap to respect newline characters in description */}

{formation.desc}

{/* Link to formation (if available) */} {formation.link && (
Web Site{" "}
)}
) : ( <> {/* Right/Content Column (now on left visually) */}

{formation.name}

{formation.desc}

{/* Link to formation (if available) */} {formation.link && (
Web Site{" "}
)}
{/* Left/Image Column (now on right visually) */}
{`${formation.name}
)}
))}
); }; export default Educations;