import { auth } from "@/auth"; import { db } from "@/lib/db"; import { hasPermission } from "@/lib/permissions"; import { redirect } from "next/navigation"; import Link from "next/link"; import { formatCurrency, formatDate, PO_STATUS_LABELS } from "@/lib/utils"; import { PaymentActions } from "./payment-actions"; import type { Metadata } from "next"; export const metadata: Metadata = { title: "Payments" }; export default async function PaymentsPage() { const session = await auth(); if (!session?.user) redirect("/login"); if (!hasPermission(session.user.role, "process_payment")) redirect("/dashboard"); const queue = await db.purchaseOrder.findMany({ where: { status: { in: ["MGR_APPROVED", "SENT_FOR_PAYMENT", "PARTIALLY_PAID", "PARTIALLY_CLOSED"] } }, include: { submitter: true, vessel: true, site: { select: { name: true } }, account: true, vendor: true }, orderBy: { approvedAt: "asc" }, }); return (
{queue.length} order{queue.length !== 1 ? "s" : ""} in the payment pipeline
No orders in the payment queue.