import React, { useEffect, useState } from 'react'; import { Container, Typography, CircularProgress, Alert, Grid, Card, CardContent, Button, Box, Chip, } from '@mui/material'; import { Link } from 'react-router-dom'; import axios from 'axios'; import type { JobOffer, JobSearchResponse } from '../types'; const API_BASE_URL = 'http://localhost:3000/api/jobs'; const JobList: React.FC = () => { const [jobs, setJobs] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { const fetchJobs = async () => { try { setLoading(true); const response = await axios.get(API_BASE_URL); setJobs(response.data.jobs); setError(null); } catch (err) { console.error("Erreur lors de la récupération des offres:", err); setError("Impossible de charger les offres pour le moment. Veuillez réessayer plus tard."); setJobs([]); } finally { setLoading(false); } }; fetchJobs(); }, []); return ( Découvrez les dernières offres d'emploi {loading && ( )} {error && ( {error} )} {!loading && !error && jobs.length === 0 && ( Aucune offre d'emploi disponible pour le moment. )} {!loading && !error && jobs.length > 0 && ( {jobs.map((job) => ( {job.title} {job.companyName || 'Entreprise non spécifiée'} {job.contractType && ( )} {job.locationLabel && ( )} {job.description} ))} )} ); }; export default JobList;