import DashboardLayout from "@/components/DashboardLayout" import { auth } from "@/lib/auth" import { prisma } from "@/lib/prisma" import Link from "next/link" import { notFound } from "next/navigation" export default async function ReportViewPage({ params, }: { params: Promise<{ id: string }> }) { const { id } = await params const session = await auth() const manager = await prisma.shiftManager.findFirst({ where: { email: session?.user?.email || "" } }) if (!manager) return
Manager not found
const report = await prisma.machineShiftReport.findFirst({ where: { id, shift: { shiftManagerId: manager.id } }, include: { worker: true, machine: true, shift: { include: { shiftTeamMembers: { include: { team: true } } } } } }) if (!report) notFound() const { worker, machine, shift } = report const team = shift.shiftTeamMembers[0]?.team return (
← Back to Shift Details

Operator Report

{/* Report Header */}

Operator

{worker.firstName} {worker.surname}

{worker.email || 'N/A'}

Machine

{machine.name}

{machine.machineType}

Shift

{shift.name}

{new Date(shift.shiftDate).toLocaleDateString()}

Team

{team?.name || 'N/A'}

Submitted At

{new Date(report.createdAt).toLocaleString()}

Last Updated

{new Date(report.updatedAt).toLocaleString()}

{/* Report Sections */}
{/* Safety Checklist */} {report.safetyChecklist && ( )} {/* Production Parameters */} {report.productionParameters && ( )} {/* Bottle Weight Tracking */} {report.bottleWeightTracking && ( )} {/* Hourly Quality Checks */} {report.hourlyQualityChecks && ( )} {/* Production Tracking */} {report.productionTracking && ( )} {/* Seam Leak Test */} {report.seamLeakTest && ( )} {/* Film Details */} {report.filmDetails && ( )} {/* Wall Thickness */} {report.wallThickness && ( )} {/* Section Weights */} {report.sectionWeights && ( )} {/* Station 1 Weights */} {report.station1Weights && ( )} {/* Quality Metrics */} {report.qualityMetrics && ( )} {/* Output Metrics */} {report.outputMetrics && ( )} {/* Summary Data */} {(report.averageWeight || report.totalBagsMade) && (

Summary

{report.averageWeight && (

Average Weight

{report.averageWeight} g

)} {report.totalBagsMade && (

Total Bags Made

{report.totalBagsMade}

)}
)}
) } function ReportSection({ title, data }: { title: string; data: any }) { return (

{title}

          {JSON.stringify(data, null, 2)}
        
) }