Order History
Customer-facing order history view with status tracking and order details
Order History
Authenticated customers can view their complete order history at /account/orders, with recent orders also shown on the account dashboard.
Architecture
Account Dashboard
The account page (/account) is a server component that:
- Validates the session via
getServerSession(authOptions) - Redirects unauthenticated users to
/auth/signin?callbackUrl=/account - Fetches the 5 most recent orders for the current user
- Renders each order with the
OrderCardcomponent
const recentOrders = await prisma.order.findMany({
where: { userId },
orderBy: { createdAt: 'desc' },
take: 5,
select: {
id: true,
orderNumber: true,
status: true,
createdAt: true,
total: true,
},
})The dashboard also shows quick links to View Orders, Account Settings, and the Fundraising Portal (for users with the FUNDRAISER role).
Order History Page
The /account/orders page lists all orders for the authenticated user, sorted newest first. Each order row displays:
| Field | Format |
|---|---|
| Order number | JMS-YYYYMMDD-XXXX (falls back to last 6 chars of ID) |
| Date | Formatted createdAt timestamp |
| Status | Color-coded badge |
| Total | USD currency format |
Status Badges
Orders display color-coded status badges:
| Status | Color |
|---|---|
PENDING | Yellow |
CONFIRMED | Blue |
PROCESSING | Indigo |
SHIPPED | Purple |
DELIVERED | Green |
CANCELLED | Red |
REFUNDED | Gray |
Authentication
Both the dashboard and order history pages require authentication. Unauthenticated access triggers a redirect to the sign-in page with a callbackUrl parameter so the user returns to their original destination after login.
Order history is only available to authenticated users. Guest orders must be looked up separately by order number and email.
How is this guide?
Last updated on