import Link from 'next/link'; import { Plus, FolderOpen, Clock, Users, Globe, Lock, UserPlus } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { auth } from '@/lib/auth'; import { redirect } from 'next/navigation'; import { db } from '@/lib/db'; function formatRelativeTime(date: Date): string { const now = new Date(); const diffMs = now.getTime() - date.getTime(); const diffMins = Math.floor(diffMs / 60000); const diffHours = Math.floor(diffMs / 3600000); const diffDays = Math.floor(diffMs / 86400000); if (diffMins < 1) return 'just now'; if (diffMins < 60) return `${diffMins}m ago`; if (diffHours < 24) return `${diffHours}h ago`; if (diffDays < 7) return `${diffDays}d ago`; return date.toLocaleDateString(); } function VisibilityIcon({ visibility }: { visibility: string }) { switch (visibility) { case 'PUBLIC': return ; case 'INVITE': return ; default: return ; } } export default async function DashboardPage() { const session = await auth(); if (!session?.user?.id) { redirect('/login'); } // Fetch projects where user is owner or member const projects = await db.project.findMany({ where: { OR: [ { ownerId: session.user.id }, { members: { some: { userId: session.user.id } } }, ], }, include: { _count: { select: { videos: true, members: true, }, }, }, orderBy: { updatedAt: 'desc' }, }); return (
{/* Header */}

Projects

Manage your video projects and collect feedback

{/* Projects Grid */} {projects.length > 0 ? (
{projects.map((project) => (
{project.name} {project.visibility.toLowerCase()}
{project.description || 'No description'}
{formatRelativeTime(project.updatedAt)} {project._count.members + 1} {project._count.videos} videos
))}
) : (

No projects yet

Create your first project to start collecting video feedback

)}
); }