'use client'; import Link from 'next/link'; import { Plus, Building2, Clock, FolderOpen, Users } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { useRouter } from 'next/navigation'; 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(); } interface SerializedWorkspace { id: string; name: string; description: string | null; updatedAt: string; _count: { projects: number; members: number; }; } interface WorkspacesClientProps { workspaces: SerializedWorkspace[]; totalPages: number; currentPage: number; } export function WorkspacesClient({ workspaces, totalPages, currentPage }: WorkspacesClientProps) { const router = useRouter(); return (
{/* Header */}

Workspaces

Manage your workspaces and their projects

{/* Workspaces Grid */} {workspaces.length > 0 ? (
{workspaces.map((workspace) => ( {workspace.name} {workspace.description || 'No description'}
{formatRelativeTime(new Date(workspace.updatedAt))} {workspace._count.projects} projects {workspace._count.members + 1}
))}
) : (

No workspaces yet

Create a workspace to organize your projects and invite team members

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