"use client"; import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Check, X, Play, Copy, Sparkles } from "lucide-react"; import { RepurposeModal } from "./repurpose-modal"; import { VariationModal } from "./variation-modal"; interface Asset { id: string; type: string; platform?: string | null; format?: string | null; fileName: string; filePath: string; dimensions?: string | null; metadata?: string | null; status: string; createdAt: string; campaign?: { name: string }; parentAsset?: { id: string; fileName: string } | null; } interface AssetCardProps { asset: Asset; onStatusChange: (id: string, status: string) => void; selected?: boolean; onSelect?: (id: string) => void; } export function AssetCard({ asset, onStatusChange, selected, onSelect, }: AssetCardProps) { const [repurposeOpen, setRepurposeOpen] = useState(false); const [variationOpen, setVariationOpen] = useState(false); const metadata = asset.metadata ? JSON.parse(asset.metadata) : {}; const isImage = asset.type === "image" || asset.format === "png" || asset.format === "jpg"; const isVideo = asset.type === "video" || asset.format === "mp4"; const fileSrc = `/api/files/${asset.filePath}`; const pathLower = asset.filePath.toLowerCase(); const source = pathLower.includes("/gemini/") ? "Gemini" : pathLower.includes("/posters/") ? "Canvas Design" : isVideo ? "Remotion" : isImage ? "Playwright" : null; const sourceColors: Record = { Gemini: "text-purple-600 border-purple-200 bg-purple-50", "Canvas Design": "text-amber-600 border-amber-200 bg-amber-50", Remotion: "text-blue-600 border-blue-200 bg-blue-50", Playwright: "text-emerald-600 border-emerald-200 bg-emerald-50", }; return (
{/* Preview */}
onSelect?.(asset.id)} > {isImage && ( e.stopPropagation()} > {asset.fileName} )} {isVideo && ( <>
{/* Info */}
{source && ( {source} )} {asset.platform && ( {asset.platform} )} {asset.dimensions && ( {asset.dimensions} )} {asset.status}
{metadata.caption && (

{metadata.caption}

)} {asset.parentAsset && (

Derived from: {asset.parentAsset.fileName}

)}
{asset.campaign && {asset.campaign.name}} {asset.campaign && asset.createdAt && ·} {asset.createdAt && ( {new Date(asset.createdAt).toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric", })} )}
{/* Actions — only for images and videos */} {(isImage || isVideo) ? (
{isImage && (
)}
) : (

Auto-accepted

)}
{/* Modals */} {repurposeOpen && ( setRepurposeOpen(false)} /> )} {variationOpen && ( setVariationOpen(false)} /> )}
); }