fixes
Build and Push Docker Image / build (push) Successful in 1m6s

This commit is contained in:
jason
2026-04-21 20:59:55 -05:00
parent bb452a59ae
commit bc3b78aa33
17 changed files with 534 additions and 40 deletions
+13 -2
View File
@@ -29,6 +29,12 @@ export async function POST(req: NextRequest, ctx: { params: Promise<{ id: string
throw new ApiError(409, "op_not_active", "Step is not active");
}
// If the operator logged any units during this session we flip status to
// `partial` (instead of `pending`) so the scan card can say "Resume this
// step" and the counter survives across pauses.
const units = body.unitsProcessed ?? 0;
const nextStatus: "pending" | "partial" = units > 0 ? "partial" : "pending";
const now = new Date();
await prisma.$transaction(async (tx) => {
// Close the most recent open TimeLog for (op, operator). We accept that
@@ -50,7 +56,12 @@ export async function POST(req: NextRequest, ctx: { params: Promise<{ id: string
}
await tx.operation.update({
where: { id },
data: { status: "pending", claimedByUserId: null, claimedAt: null },
data: {
status: nextStatus,
claimedByUserId: null,
claimedAt: null,
...(units > 0 ? { unitsCompleted: { increment: units } } : {}),
},
});
});
@@ -60,7 +71,7 @@ export async function POST(req: NextRequest, ctx: { params: Promise<{ id: string
action: "release_op",
entity: "Operation",
entityId: id,
after: { status: "pending", unitsProcessed: body.unitsProcessed ?? null },
after: { status: nextStatus, unitsProcessed: body.unitsProcessed ?? null },
ipAddress: clientIp(req),
});