import Link from "next/link"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; export default async function AdminDashboardPage() { const [ projectsTotal, projectsActive, assembliesTotal, partsTotal, operationsTotal, operationsInProgress, machinesActive, templatesActive, operatorsActive, adminsActive, recentProjects, ] = await Promise.all([ prisma.project.count(), prisma.project.count({ where: { status: { in: ["planning", "in_progress"] } } }), prisma.assembly.count(), prisma.part.count(), prisma.operation.count(), prisma.operation.count({ where: { status: "in_progress" } }), prisma.machine.count({ where: { active: true } }), prisma.operationTemplate.count({ where: { active: true } }), prisma.user.count({ where: { role: "operator", active: true } }), prisma.user.count({ where: { role: "admin", active: true } }), prisma.project.findMany({ orderBy: { updatedAt: "desc" }, take: 5, select: { id: true, code: true, name: true, status: true, updatedAt: true, _count: { select: { assemblies: true } }, }, }), ]); return (

Dashboard

Snapshot of the shop. Click any tile to dive in.

Fasteners & POs

Purchasing lifecycle lands in step 6.

Recent projects

All projects →
{recentProjects.map((p) => ( ))} {recentProjects.length === 0 && ( )}
Code Name Status Assemblies Updated
{p.code} {p.name} {p.status} {p._count.assemblies} {p.updatedAt.toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric", })}
No projects yet.{" "} Create one .
); } function Tile({ href, title, primary, secondary, }: { href: string; title: string; primary: number; secondary: string; }) { return (

{title}

{primary}

{secondary}

); }