muller-reporting-sys/app/operator/report/[shiftId]/[machineId]/page.tsx
2025-11-12 22:21:35 +03:00

36 lines
928 B
TypeScript

import DashboardLayout from "@/components/DashboardLayout"
import { auth } from "@/lib/auth"
import { prisma } from "@/lib/prisma"
import ReportForm from "@/components/ReportForm"
export default async function ReportPage({ params }: { params: Promise<{ shiftId: string; machineId: string }> }) {
const { shiftId, machineId } = await params
const session = await auth()
const worker = await prisma.worker.findFirst({
where: { email: session?.user?.email || "" }
})
if (!worker) return <div>Worker not found</div>
const report = await prisma.machineShiftReport.findFirst({
where: {
shiftId,
machineId,
workerId: worker.id
},
include: {
shift: true,
machine: true,
worker: true
}
})
if (!report) return <div>Report not found</div>
return (
<DashboardLayout requiredRole="operator">
<ReportForm report={report} />
</DashboardLayout>
)
}