This commit is contained in:
@@ -31,6 +31,10 @@ export default async function AdminPartDetailPage({
|
||||
include: {
|
||||
machine: { select: { id: true, name: true } },
|
||||
template: { select: { id: true, name: true } },
|
||||
timeLogs: {
|
||||
orderBy: { startedAt: "desc" },
|
||||
include: { operator: { select: { id: true, name: true } } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -55,6 +59,20 @@ export default async function AdminPartDetailPage({
|
||||
]);
|
||||
if (!part) notFound();
|
||||
|
||||
// QC history across every op on the part — newest first. Same data feeds
|
||||
// two views: the "QC history" strip on the part page and the failure-digest
|
||||
// on the admin dashboard. Keeping it to the last 50 per part is plenty for
|
||||
// any realistic production run.
|
||||
const qcRecords = await prisma.qCRecord.findMany({
|
||||
where: { operation: { partId: part.id } },
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 50,
|
||||
include: {
|
||||
operator: { select: { id: true, name: true } },
|
||||
operation: { select: { id: true, sequence: true, name: true } },
|
||||
},
|
||||
});
|
||||
|
||||
const fileView = (f: typeof part.stepFile) =>
|
||||
f
|
||||
? {
|
||||
@@ -99,6 +117,14 @@ export default async function AdminPartDetailPage({
|
||||
plannedUnits: op.plannedUnits,
|
||||
status: op.status,
|
||||
qrToken: op.qrToken,
|
||||
timeLogs: op.timeLogs.map((l) => ({
|
||||
id: l.id,
|
||||
startedAt: l.startedAt.toISOString(),
|
||||
endedAt: l.endedAt ? l.endedAt.toISOString() : null,
|
||||
unitsProcessed: l.unitsProcessed,
|
||||
note: l.note,
|
||||
operatorName: l.operator.name,
|
||||
})),
|
||||
}))}
|
||||
machines={machines}
|
||||
templates={templates.map((t) => ({
|
||||
@@ -109,6 +135,17 @@ export default async function AdminPartDetailPage({
|
||||
defaultInstructions: t.defaultInstructions,
|
||||
qcRequired: t.qcRequired,
|
||||
}))}
|
||||
qcRecords={qcRecords.map((r) => ({
|
||||
id: r.id,
|
||||
kind: r.kind,
|
||||
passed: r.passed,
|
||||
notes: r.notes,
|
||||
measurements: r.measurements,
|
||||
createdAt: r.createdAt.toISOString(),
|
||||
operatorName: r.operator.name,
|
||||
operationSequence: r.operation.sequence,
|
||||
operationName: r.operation.name,
|
||||
}))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user