import { useState } from 'react'; import { motion } from 'motion/react'; import { YoutubeFilled } from '../icons/FilledIcons'; import { SectionWrapper } from '../report/ui/SectionWrapper'; import AssetDetailModal from './AssetDetailModal'; import type { AssetCollectionData, AssetCard, YouTubeRepurposeItem, AssetSource, AssetStatus, AssetType } from '../../types/plan'; type ModalAsset = | { kind: 'asset'; data: AssetCard } | { kind: 'youtube'; data: YouTubeRepurposeItem }; interface AssetCollectionProps { data: AssetCollectionData; } const filterTabs = [ { key: 'all', label: '전체' }, { key: 'homepage', label: '홈페이지' }, { key: 'naver_place', label: '네이버' }, { key: 'blog', label: '블로그' }, { key: 'social', label: '소셜미디어' }, { key: 'youtube', label: 'YouTube' }, ] as const; type FilterKey = (typeof filterTabs)[number]['key']; const sourceBadgeColors: Record = { homepage: 'bg-slate-100 text-slate-700', naver_place: 'bg-[#F3F0FF] text-[#4A3A7C]', blog: 'bg-[#EFF0FF] text-[#3A3F7C]', social: 'bg-[#FFF0F0] text-[#7C3A4B]', youtube: 'bg-[#FFF0F0] text-[#7C3A4B]', }; const typeBadgeColors: Record = { photo: 'bg-[#EFF0FF] text-[#3A3F7C]', video: 'bg-[#F3F0FF] text-[#4A3A7C]', text: 'bg-[#FFF6ED] text-[#7C5C3A]', }; const statusConfig: Record = { collected: { className: 'bg-[#F3F0FF] text-[#4A3A7C]', label: '수집완료' }, pending: { className: 'bg-[#FFF6ED] text-[#7C5C3A]', label: '수집 대기' }, needs_creation: { className: 'bg-[#FFF0F0] text-[#7C3A4B]', label: '제작 필요' }, }; function formatViews(views: number): string { if (views >= 1_000_000) return `${(views / 1_000_000).toFixed(1)}M`; if (views >= 1_000) return `${Math.round(views / 1_000)}K`; return String(views); } export default function AssetCollection({ data }: AssetCollectionProps) { const [activeFilter, setActiveFilter] = useState('all'); const [selectedAsset, setSelectedAsset] = useState(null); const filteredAssets = activeFilter === 'all' ? data.assets : data.assets.filter((a) => a.source === activeFilter); return ( {/* Source Filter Tabs */}
{filterTabs.map((tab) => ( ))}
{/* Asset Cards Grid */}
{filteredAssets.map((asset, i) => { const statusInfo = statusConfig[asset.status]; return ( setSelectedAsset({ kind: 'asset', data: asset })} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.4, delay: i * 0.05 }} > {/* Top badges row */}
{asset.sourceLabel} {asset.type} {statusInfo.label}
{/* Title & Description */}

{asset.title}

{asset.description}

{/* Repurposing suggestions */} {asset.repurposingSuggestions.length > 0 && (

Repurposing →

{asset.repurposingSuggestions.map((suggestion, j) => ( {suggestion} ))}
)}
); })}
{/* YouTube Repurpose Section */} {data.youtubeRepurpose.length > 0 && (

YouTube Top Videos for Repurposing

{data.youtubeRepurpose.map((video, i) => ( setSelectedAsset({ kind: 'youtube', data: video })} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.4, delay: i * 0.1 }} >

{video.title}

{formatViews(video.views)} views {video.type}

Repurpose As:

{video.repurposeAs.map((suggestion, j) => ( {suggestion} ))}
))}
)} setSelectedAsset(null)} />
); }