import { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; import { apiFetch } from '../lib/api'; interface Video { id: string; title: string; description: string; requiredLevel: number; locked: boolean; thumbnailUrl?: string; } interface VideosResponse { success: boolean; data: { videos: Video[] }; } export default function HomePage() { const [videos, setVideos] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { apiFetch('/videos') .then((res) => setVideos(res.data.videos)) .catch(() => setVideos([])) .finally(() => setLoading(false)); }, []); const free = videos.filter((v) => !v.locked); const premium = videos.filter((v) => v.locked); return (
{/* Hero */}

Vidéos & formations

Contenu libre et premium — connecte-toi pour accéder aux formations complètes.

{loading && (
{[...Array(4)].map((_, i) => )}
)} {!loading && ( <> {free.length > 0 && (

Accès libre

{free.map((v) => )}
)} {premium.length > 0 && (

Premium

{premium.map((v) => )}
)} {videos.length === 0 && (

Aucune vidéo disponible pour l'instant.

)} )}
); } function VideoCard({ video }: { video: Video }) { const inner = (
{/* Thumbnail */}
{video.thumbnailUrl && ( {video.title} )} {video.locked && (
)}

{video.title}

{video.description && (

{video.description}

)}
{video.locked ? ( Premium ) : ( Libre )}
); if (video.locked) return
{inner}
; return {inner}; } function VideoCardSkeleton() { return (
); }