import { useApp } from '../store'; import { getChannel, getChannelPlaylists, getPlaylistVideos, standaloneVideos, formatNumber, getCategoryColor } from '../data'; import { ArrowRight, Play, List, CheckCircle, Users, Video } from 'lucide-react'; export default function ChannelView({ channelId }: { channelId: string }) { const { setView, progress, followedChannelIds, followChannel, unfollowChannel } = useApp(); const channel = getChannel(channelId); if (!channel) { return
القناة غير موجودة
; } const isFollowed = followedChannelIds.includes(channelId); const channelPlaylists = getChannelPlaylists(channelId); const channelStandalone = standaloneVideos.filter(v => v.channelId === channelId); const totalVideos = channelPlaylists.reduce((sum, pl) => sum + (getPlaylistVideos(pl.id)?.length || 0), 0) + channelStandalone.length; const watchedCount = [ ...channelStandalone, ...channelPlaylists.flatMap(pl => getPlaylistVideos(pl.id) || []) ].filter(v => progress.watchedVideos.includes(v.id)).length; return (
{/* Channel Header */}
{channel.emoji}

{channel.name}

{channel.description}

{formatNumber(channel.subscriberCount)} مشترك {channelPlaylists.length} قائمة تشغيل
{/* Categories */}
{channel.categories.map(cat => ( {cat} ))}
{/* Stats */}
{watchedCount}/{totalVideos}
فيديو مُشاهد
{channelPlaylists.filter(pl => progress.completedPlaylists.includes(pl.id)).length}/{channelPlaylists.length}
قوائم مكتملة
{totalVideos > 0 && (
التقدم الكلي
{Math.round((watchedCount / totalVideos) * 100)}%
)}
{/* Playlists */}

قوائم التشغيل ({channelPlaylists.length})

{channelPlaylists.map(pl => { const plVideos = getPlaylistVideos(pl.id); const completedCount = plVideos.filter(v => progress.watchedVideos.includes(v.id)).length; const percentage = plVideos.length > 0 ? Math.round((completedCount / plVideos.length) * 100) : 0; const isComplete = progress.completedPlaylists.includes(pl.id); return ( ); })}
{/* Standalone Videos */} {channelStandalone.length > 0 && ( <>

{channelStandalone.map(video => { const isWatched = progress.watchedVideos.includes(video.id); return ( ); })}
)}
); }