import React, { useState, useEffect } from 'react'; import { Loader2, Download, History as HistoryIcon, Film } from 'lucide-react'; import { apiJson } from '../lib/api'; // The signed-in user's saved video library (stored in R2). Private, signed links. export default function HistoryTab() { const [videos, setVideos] = useState(null); const [error, setError] = useState(''); useEffect(() => { apiJson('/api/history') .then((d) => setVideos(d.videos || [])) .catch(() => setError('Could not load your library.')); }, []); const fmtDate = (iso) => (iso ? new Date(iso).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' }) : ''); if (videos === null && !error) { return
; } return (

Your library

All the shorts you've generated, saved while your plan is active. Kept for 7 days after your plan ends.

{error &&

{error}

} {videos && videos.length === 0 && (

No videos yet. Generate your first short from the Clip Generator.

)}
{(videos || []).map((v) => (

{v.title || 'Short'}

{fmtDate(v.created_at)} Download
))}
); }