import React, { useState, useEffect } from 'react'; import { Film, Download, Copy, Check, Loader2, Play, User } from 'lucide-react'; import { getApiUrl } from '../config'; import SegmentedControl from './ui/SegmentedControl'; import Modal from './ui/Modal'; export default function UGCGallery() { const [tab, setTab] = useState('videos'); const [videos, setVideos] = useState([]); const [avatars, setAvatars] = useState([]); const [loadingVideos, setLoadingVideos] = useState(true); const [loadingAvatars, setLoadingAvatars] = useState(false); const [avatarsLoaded, setAvatarsLoaded] = useState(false); const [copied, setCopied] = useState(''); const [selected, setSelected] = useState(null); useEffect(() => { setLoadingVideos(true); fetch(getApiUrl('/api/saasshorts/gallery?limit=100')) .then((r) => (r.ok ? r.json() : { videos: [] })) .then((d) => setVideos(d.videos || [])) .catch(() => {}) .finally(() => setLoadingVideos(false)); }, []); useEffect(() => { if (tab !== 'avatars' || avatarsLoaded) return; setLoadingAvatars(true); fetch(getApiUrl('/api/saasshorts/actor-gallery')) .then((r) => (r.ok ? r.json() : { images: [] })) .then((d) => setAvatars(d.images || [])) .catch(() => {}) .finally(() => { setLoadingAvatars(false); setAvatarsLoaded(true); }); }, [tab, avatarsLoaded]); const handleCopy = (text, id) => { navigator.clipboard.writeText(text); setCopied(id); setTimeout(() => setCopied(''), 2000); }; const loading = (tab === 'videos' && loadingVideos) || (tab === 'avatars' && loadingAvatars); return (
05 · UGC GALLERY
{loadingVideos ? '…' : videos.length} videos {avatarsLoaded ? ` · ${avatars.length} avatars` : ''}
No videos yet. Generate one from AI Shorts.
No avatars yet. Generate actors from AI Shorts.
{selected.duration?.toFixed(0)}s {selected.cost_estimate?.total != null ? ` · $${selected.cost_estimate.total.toFixed(2)}` : ''}
{selected.caption && ({selected.caption}
)}{video.duration?.toFixed(0)}s · ${video.cost_estimate?.total?.toFixed(2) || '?'}
{caption && ({caption}