import { Suspense } from 'react' import Link from 'next/link' import { prisma } from '@/lib/prisma' export const dynamic = 'force-dynamic' import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { Plus, MoreHorizontal, FolderKanban, Eye, Pencil, } from 'lucide-react' import { formatDateOnly } from '@/lib/utils' async function ProgramsContent() { const programs = await prisma.program.findMany({ // Note: PROGRAM_ADMIN filtering should be handled via middleware or a separate relation include: { _count: { select: { rounds: true, }, }, rounds: { where: { status: 'ACTIVE' }, select: { id: true }, }, }, orderBy: { createdAt: 'desc' }, }) if (programs.length === 0) { return ( No programs yet Create your first program to start managing projects and rounds Create Program ) } const statusColors: Record = { ACTIVE: 'default', COMPLETED: 'success', DRAFT: 'secondary', ARCHIVED: 'secondary', } return ( <> {/* Desktop table view */} Program Year Rounds Status Created Actions {programs.map((program) => ( {program.name} {program.description && ( {program.description} )} {program.year} {program._count.rounds} total {program.rounds.length > 0 && ( {program.rounds.length} active )} {program.status} {formatDateOnly(program.createdAt)} Actions View Details Edit ))} {/* Mobile card view */} {programs.map((program) => ( {program.name} {program.year} {program.status} Rounds {program._count.rounds} ({program.rounds.length} active) Created {formatDateOnly(program.createdAt)} View Edit ))} > ) } function ProgramsSkeleton() { return ( {[...Array(5)].map((_, i) => ( ))} ) } export default function ProgramsPage() { return ( {/* Header */} Programs Manage your ocean protection programs New Program {/* Content */} }> ) }
No programs yet
Create your first program to start managing projects and rounds
{program.name}
{program.description}
{program._count.rounds} total
{program.rounds.length} active
Manage your ocean protection programs