import { auth } from "@/auth"; import { db } from "@/lib/db"; import { redirect } from "next/navigation"; import Link from "next/link"; import { formatCurrency, formatDate } from "@/lib/utils"; import { PoStatusBadge } from "@/components/po/po-status-badge"; import type { Metadata } from "next"; export const metadata: Metadata = { title: "Closed Purchase Orders" }; export default async function MyOrdersPage() { const session = await auth(); if (!session?.user) redirect("/login"); const { role, id: userId } = session.user; if (!["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"].includes(role)) redirect("/dashboard"); const closed = await db.purchaseOrder.findMany({ where: { submitterId: userId, status: { in: ["MGR_APPROVED", "SENT_FOR_PAYMENT", "PAID_DELIVERED", "CLOSED", "REJECTED"] }, }, orderBy: { updatedAt: "desc" }, include: { vessel: { select: { name: true } }, account: { select: { name: true, code: true } }, }, }); return (
No closed purchase orders yet.
View active orders on the dashboard →| PO Number | Title | Cost Centre | Status | Amount | Updated |
|---|---|---|---|---|---|
| {po.poNumber} |
{po.title}
{po.managerNote && (
Note: {po.managerNote} )} |
{po.vessel.name} | {formatCurrency(Number(po.totalAmount))} | {formatDate(po.updatedAt)} |