diff --git a/src/pages/CreateServer/modpack/modpack.jsx b/src/pages/CreateServer/modpack/modpack.jsx index 57e8345..485816b 100644 --- a/src/pages/CreateServer/modpack/modpack.jsx +++ b/src/pages/CreateServer/modpack/modpack.jsx @@ -1,13 +1,39 @@ +import React, { useEffect, useState } from 'react'; import styles from './modpack.module.scss'; import PropTypes from "prop-types"; import Navbar from '../../../components/navbar/Navbar'; import { useNavigate } from 'react-router-dom'; - +import serviiApi from '../../../service/api'; const Modpack = ({ user }) => { const navigate = useNavigate(); + const [modpacks, setModpacks] = useState([]); + const [error, setError] = useState(''); + + useEffect(() => { + const fetchModpacks = async () => { + if (!user) { + setError("Vous devez ĂȘtre connectĂ© pour voir les modpacks."); + return; + } + + try { + const response = await serviiApi.fetchModpacks(); + console.log(response); + if (response.return_code === 200) { + setModpacks(response.message); + } else { + setError(response.message); + } + } catch (error) { + console.error(error); + setError("Erreur lors du chargement des modpacks."); + } + }; + + fetchModpacks(); + }, [user]); - return (