import Link from "next/link"; import { requireOperator } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; /** * Operator dashboard. Because phones often have the browser open between scans, * we want this page to answer one question fast: "what am I currently working * on?" Active claims are the headline list; below that we show a generic * "scan a card to start" hint so a fresh operator knows what to do. */ export default async function OperatorHomePage() { const user = await requireOperator(); const claims = await prisma.operation.findMany({ where: { claimedByUserId: user.id, status: "in_progress" }, orderBy: { claimedAt: "desc" }, include: { machine: { select: { name: true } }, part: { select: { code: true, name: true, assembly: { select: { code: true, project: { select: { code: true, name: true } }, }, }, }, }, }, }); return (

Hi, {user.name}

Scan a QR card with your phone camera to start a step, or continue an active one below.

{claims.length === 0 ? (
You have no active steps. Scan a traveler QR to begin.
) : (

Active ({claims.length})

{claims.map((c) => (
{c.part.assembly.project.code} ยท {c.part.assembly.code}
{c.part.name}
Step {c.sequence}: {c.name}
{c.part.code} {c.machine ? {c.machine.name} : null} {c.claimedAt ? since {new Date(c.claimedAt).toLocaleTimeString()} : null}
))}
)}
); }