import { Metadata } from "next"; import Link from "next/link"; import { auth } from "@/auth"; import { redirect } from "next/navigation"; import { db } from "@/lib/db"; import { PlusCircle, Building2, Mail, User2, FolderOpen } from "lucide-react"; import { Button } from "@/components/ui/button"; import { NewClientDialog } from "@/components/clients/NewClientDialog"; import { cn } from "@/lib/utils"; export const metadata: Metadata = { title: "Clients" }; async function getClients() { return db.client.findMany({ orderBy: { company: "asc" }, include: { _count: { select: { projects: true } } }, }); } export default async function ClientsPage() { const session = await auth(); if (!session || !["ADMIN", "PRODUCER"].includes(session.user.role as string)) { redirect("/dashboard"); } const clients = await getClients(); return (
{/* Header */}

Clients

{clients.length} client{clients.length !== 1 ? "s" : ""} total

{/* Grid */} {clients.length === 0 ? (

No clients yet

Add your first client to start sharing reviews.

) : (
{clients.map((client) => ( {/* Avatar + company */}

{client.company}

{client.isActive ? "Active" : "Inactive"}
{/* Details */}
{client.contactPerson && (
{client.contactPerson}
)} {client.email && (
{client.email}
)}
{/* Project count */}
{client._count.projects} project{client._count.projects !== 1 ? "s" : ""}
))}
)}
); }