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 <noreply@anthropic.com>
This commit is contained in:
parent
cf9ff40262
commit
d4007ee222
3 changed files with 15 additions and 20 deletions
|
|
@ -63,7 +63,7 @@ async function SubmitterDashboard({ userId }: { userId: string }) {
|
|||
+ New Purchase Order
|
||||
</a>
|
||||
<Link href="/my-orders" className="text-sm text-primary-600 hover:text-primary-700 font-medium">
|
||||
View all my purchase orders →
|
||||
View closed purchase orders →
|
||||
</Link>
|
||||
</div>
|
||||
{recentPos.length > 0 && (
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div>
|
||||
<div className="mb-6 flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-neutral-900">My Purchase Orders</h1>
|
||||
<h1 className="text-2xl font-semibold text-neutral-900">Closed Purchase Orders</h1>
|
||||
<Link
|
||||
href="/po/new"
|
||||
className="rounded-lg bg-primary-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-primary-700 transition-colors"
|
||||
|
|
@ -43,13 +39,12 @@ export default async function MyOrdersPage() {
|
|||
</Link>
|
||||
</div>
|
||||
|
||||
<PoTable title="Open Orders" rows={open} />
|
||||
{closed.length > 0 && <PoTable title="Past Orders" rows={closed} className="mt-8" />}
|
||||
{pos.length === 0 && (
|
||||
<PoTable title="Closed Orders" rows={closed} />
|
||||
{closed.length === 0 && (
|
||||
<div className="rounded-lg border border-neutral-200 bg-white p-12 text-center">
|
||||
<p className="text-neutral-500">You haven't raised any purchase orders yet.</p>
|
||||
<Link href="/po/new" className="mt-4 inline-block text-sm text-primary-600 hover:underline font-medium">
|
||||
Create your first PO →
|
||||
<p className="text-neutral-500">No closed purchase orders yet.</p>
|
||||
<Link href="/dashboard" className="mt-4 inline-block text-sm text-primary-600 hover:underline font-medium">
|
||||
View active orders on the dashboard →
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -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"] },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue