import { useState } from 'react'
import { Download, Plus, TrendingUp, Clock, Tag, Film, ExternalLink } from 'lucide-react'
import clsx from 'clsx'
import ClipCard from './ClipCard'
/**
* Clips gallery — handles both video clip jobs AND article reel jobs.
* Props: { jobResult, jobId, jobType, onReset }
*/
function ClipsGallery({ jobResult, jobId, jobType = 'clip', onReset }) {
const [sortBy, setSortBy] = useState('score')
const [selectedTopic, setSelectedTopic] = useState(null)
// ── ARTICLE REEL result ──────────────────────────────────────────────────
if (jobType === 'article') {
return (
Your Article Reel is Ready!
Complete with AI voiceover and chainstreet.io CTA
{/* Script preview */}
{jobResult?.sentences?.length > 0 && (
Script
{jobResult.sentences.map((line, i) => (
))}
)}
This reel includes a "Read the full story at chainstreet dot i o" call-to-action — perfect for driving traffic from social media back to your article.
)
}
// ── VIDEO CLIPS result ───────────────────────────────────────────────────
if (!jobResult || !jobResult.clips) {
return (
No clips generated yet
)
}
const clips = jobResult.clips || []
const allTopics = [...new Set(clips.flatMap((c) => c.topics || []))]
// Filter clips by topic
let filteredClips = clips
if (selectedTopic) {
filteredClips = clips.filter((c) => c.topics?.includes(selectedTopic))
}
// Sort clips
const sortedClips = [...filteredClips].sort((a, b) => {
if (sortBy === 'score') {
return (b.virality_score || 0) - (a.virality_score || 0)
} else if (sortBy === 'duration') {
return (b.duration || 0) - (a.duration || 0)
} else if (sortBy === 'match') {
return (b.match_score || 0) - (a.match_score || 0)
}
return 0
})
const downloadAllClips = () => {
// Mock implementation - would batch download all clips
alert('Downloading all clips...')
}
return (
{/* Header */}
{clips.length} Viral Clips Ready
Pick your favorites and download them instantly
{/* Sorting & Filtering */}
{/* Sort Tabs */}
{/* Topic Filter */}
{allTopics.length > 0 && (
{allTopics.map((topic) => (
))}
)}
{/* Clips Grid */}
{sortedClips.length > 0 ? (
{sortedClips.map((clip, idx) => (
))}
) : (
No clips match your filters
)}
{/* Bottom CTA */}
Need more clips?
Adjust settings and regenerate with different parameters
)
}
export default ClipsGallery