From d4007ee2223c5e0492307b20ec1ac04157de8ca5 Mon Sep 17 00:00:00 2001 From: Hardik Date: Wed, 27 May 2026 04:21:53 +0530 Subject: [PATCH] feat(my-orders): rename to Closed Purchase Orders, show only closed POs Open POs are already visible on the dashboard. The /my-orders page now fetches and displays only completed/closed statuses (MGR_APPROVED through REJECTED) and is labelled 'Closed Purchase Orders' throughout. Co-Authored-By: Claude Sonnet 4.6 --- App/app/(portal)/dashboard/page.tsx | 2 +- App/app/(portal)/my-orders/page.tsx | 31 ++++++++++++----------------- App/components/layout/sidebar.tsx | 2 +- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/App/app/(portal)/dashboard/page.tsx b/App/app/(portal)/dashboard/page.tsx index 8c54ae5..81436d7 100644 --- a/App/app/(portal)/dashboard/page.tsx +++ b/App/app/(portal)/dashboard/page.tsx @@ -63,7 +63,7 @@ async function SubmitterDashboard({ userId }: { userId: string }) { + New Purchase Order - View all my purchase orders → + View closed purchase orders → {recentPos.length > 0 && ( diff --git a/App/app/(portal)/my-orders/page.tsx b/App/app/(portal)/my-orders/page.tsx index a0acc52..1e95f25 100644 --- a/App/app/(portal)/my-orders/page.tsx +++ b/App/app/(portal)/my-orders/page.tsx @@ -2,11 +2,11 @@ import { auth } from "@/auth"; import { db } from "@/lib/db"; import { redirect } from "next/navigation"; import Link from "next/link"; -import { formatCurrency, formatDate, PO_STATUS_LABELS, PO_STATUS_VARIANTS } from "@/lib/utils"; +import { formatCurrency, formatDate } from "@/lib/utils"; import { PoStatusBadge } from "@/components/po/po-status-badge"; import type { Metadata } from "next"; -export const metadata: Metadata = { title: "My Purchase Orders" }; +export const metadata: Metadata = { title: "Closed Purchase Orders" }; export default async function MyOrdersPage() { const session = await auth(); @@ -15,8 +15,11 @@ export default async function MyOrdersPage() { const { role, id: userId } = session.user; if (!["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"].includes(role)) redirect("/dashboard"); - const pos = await db.purchaseOrder.findMany({ - where: { submitterId: userId }, + 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 } }, @@ -24,17 +27,10 @@ export default async function MyOrdersPage() { }, }); - const open = pos.filter((p) => - ["DRAFT", "SUBMITTED", "MGR_REVIEW", "VENDOR_ID_PENDING", "EDITS_REQUESTED", "PARTIALLY_CLOSED", "PARTIALLY_PAID"].includes(p.status) - ); - const closed = pos.filter((p) => - ["MGR_APPROVED", "SENT_FOR_PAYMENT", "PAID_DELIVERED", "CLOSED", "REJECTED"].includes(p.status) - ); - return (
-

My Purchase Orders

+

Closed Purchase Orders

- - {closed.length > 0 && } - {pos.length === 0 && ( + + {closed.length === 0 && (
-

You haven't raised any purchase orders yet.

- - Create your first PO → +

No closed purchase orders yet.

+ + View active orders on the dashboard →
)} diff --git a/App/components/layout/sidebar.tsx b/App/components/layout/sidebar.tsx index 3e82f2c..ca7676b 100644 --- a/App/components/layout/sidebar.tsx +++ b/App/components/layout/sidebar.tsx @@ -35,7 +35,7 @@ interface NavItem { const NAV_ITEMS: NavItem[] = [ { href: "/dashboard", label: "Dashboard", icon: LayoutDashboard }, { href: "/po/new", label: "New PO", icon: Plus, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, - { href: "/my-orders", label: "My Purchase Orders", icon: FileText, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, + { href: "/my-orders", label: "Closed Purchase Orders", icon: FileText, roles: ["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"] }, { href: "/po/import", label: "Import PO", icon: Upload, roles: ["MANAGER", "SUPERUSER"] }, { href: "/approvals", label: "Approvals", icon: CheckSquare, roles: ["MANAGER", "SUPERUSER"] }, { href: "/payments", label: "Payments", icon: CreditCard, roles: ["ACCOUNTS"] },