import Link from 'next/link'; import { redirect } from 'next/navigation'; import { getCustomerUser } from '@/app/lib/lumen-auth'; import { commerceDb } from '@/app/lib/commerce-db'; import { displayOrderId, IN_STUDIO_STATUSES } from '@/app/lib/orders'; import { PasskeyPanel } from '@/app/components/PasskeyPanel'; export const dynamic = 'force-dynamic'; export default async function OrdersPage() { const user = await getCustomerUser(); if (!user) redirect('/login?next=/orders'); const admin = commerceDb(); // Hide pending_payment rows from the customer's commissions list — // those are abandoned-cart rows from before Stripe completed, not // real commissions in the studio. If the customer wants to resume, // the Stripe-cancel return URL (/checkout?orderId=…&canceled=1) // gives them a "Resume payment" path; we don't surface them here. const { data: orders } = await admin .from('orders') .select('id, status, price_cents, created_at, config') .eq('user_id', user.id) .in('status', [...IN_STUDIO_STATUSES]) .order('created_at', { ascending: false }); return (

Your commissions

Saved photos {!orders || orders.length === 0 ? (

No commissions yet.

Start a commission
) : (
    {orders.map(o => (
  • {displayOrderId(o.id)} {statusLabel(o.status)}
    ${(o.price_cents / 100).toFixed(2)} {new Date(o.created_at).toLocaleDateString()}
  • ))}
)}
); } function statusLabel(s: string): string { switch (s) { // pending_payment / abandoned shouldn't reach this list (filtered // out at the query), but label them so any stray row doesn't // render raw. case 'pending_payment': return 'Checkout not complete'; case 'abandoned': return 'Checkout abandoned'; case 'pending_design': return 'In the design queue'; case 'awaiting_approval': return 'Proof ready — review'; case 'revision_requested': return 'Revision in progress'; case 'approved': return 'Approved — final studio review'; case 'fulfillment_submitting': return 'Payment received · sending to printer'; case 'fulfillment_review': return 'Payment received · checking print order'; case 'in_production': return 'In production'; case 'shipped': return 'Shipped'; case 'cancelled': return 'Cancelled'; default: return s; } }