import { auth } from "@/auth" import { prisma } from "@/lib/prisma" import { redirect } from "next/navigation" import { Link2 } from "lucide-react" interface AdminConnection { id: string status: string createdAt: Date updatedAt: Date store: { businessName: string shopifyStoreName: string } supplier: { companyName: string } } async function getConnections(): Promise { const connections = await prisma.connection.findMany({ include: { store: { select: { businessName: true, shopifyStoreName: true } }, supplier: { select: { companyName: true } }, }, orderBy: { createdAt: "desc" }, }) return connections as unknown as AdminConnection[] } export default async function AdminConnectionsPage() { const session = await auth() if (!session || session.user.role !== "ADMIN") { redirect("/login") } const connections = await getConnections() return (

Connections

Read-only view of vendor ↔ supplier connections across the platform.

{connections.length === 0 && ( )} {connections.map((connection) => ( ))}
Vendor Store Supplier Status Created Last Updated
No connections found.
{connection.store.businessName}
{connection.store.shopifyStoreName}
{connection.supplier.companyName}
{new Date(connection.createdAt).toLocaleString("en-US", { dateStyle: "short", timeStyle: "short", })} {new Date(connection.updatedAt).toLocaleString("en-US", { dateStyle: "short", timeStyle: "short", })}
) } function StatusPill({ status }: { status: string }) { const normalized = status.toUpperCase() let color = "bg-slate-800/60 text-slate-200 border-slate-500/40" if (normalized === "CONNECTED") { color = "bg-emerald-500/15 text-emerald-200 border-emerald-500/40" } else if (normalized === "PENDING") { color = "bg-amber-500/15 text-amber-200 border-amber-500/40" } else if (normalized === "REJECTED") { color = "bg-rose-500/15 text-rose-200 border-rose-500/40" } return ( {normalized} ) }