'use client'; import { useCallback, useEffect, useState } from 'react'; import { useRouter, useSearchParams } from 'next/navigation'; import Link from 'next/link'; import { Plus, Settings, Share2, Play, Users, Building2, ArrowUp, ArrowDown, Globe, UserPlus, Lock, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { VideoCard } from '@/components/video-card'; import { VideoDragDropUploader } from '@/components/video-drag-drop-uploader'; interface SerializedVideo { id: string; title: string; thumbnailUrl: string; currentVersion: number; commentCount: number; duration: string; lastUpdated: string; updatedAt: string; } interface ProjectContentClientProps { project: { name: string; description: string | null; visibility: string; workspace: { id: string; name: string } | null; members: { role: string }[]; }; projectId: string; videos: SerializedVideo[]; canEdit: boolean; isOwner: boolean; workspaceRole: string | null; totalPages: number; currentPage: number; } export function ProjectContentClient({ project, projectId, videos, canEdit, isOwner, totalPages, currentPage }: ProjectContentClientProps) { const router = useRouter(); const searchParams = useSearchParams(); const sortOrder = searchParams.get('sort') || 'desc'; const [localVideos, setLocalVideos] = useState(videos); useEffect(() => { setLocalVideos(videos); }, [videos]); const createQueryString = useCallback( (name: string, value: string) => { const params = new URLSearchParams(searchParams.toString()); params.set(name, value); if (name !== 'page') { params.set('page', '1'); } return params.toString(); }, [searchParams] ); const handleVideoDeleted = useCallback((videoId: string) => { setLocalVideos((prev) => prev.filter((video) => video.id !== videoId)); }, []); return ( <> {/* Project Header */}

{project.name}

{project.visibility === 'PUBLIC' && } {project.visibility === 'INVITE' && } {project.visibility === 'PRIVATE' && } {project.visibility.toLowerCase()}
{project.workspace && ( {project.workspace.name} )} {project.description && ( {project.description} )}
{/* Sort Button - Left of Share */} {canEdit && ( )} {(isOwner || project.members[0]?.role === 'ADMIN') && ( <> )} {canEdit && ( )}
{/* Videos Grid */} {localVideos.length > 0 ? (
{localVideos.map((video) => ( ))}
) : (

No videos yet

Add your first video to start collecting feedback

{canEdit && ( )}
)} {/* Pagination */} {totalPages > 1 && (
Page {currentPage} of {totalPages}
)} ); }