Fix: Show approved designs in customer account so they can order

- Add query for approved designs (status = 'APPROVED')
- Display 'Ready to order' section in customer account
- Link directly to checkout with design pre-selected
- Show estimated delivery date if set
- Add success message when admin approves design

Now when admin approves a design with expected delivery date:
1. Customer sees it in 'Ready to order' section
2. Can click to view and proceed to payment
3. Can see estimated delivery date

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-22 05:38:51 +01:00
co-authored by Claude Haiku 4.5
parent 234f03b4dd
commit 0f119b5db5
3 changed files with 42 additions and 1 deletions
+2 -1
View File
@@ -162,7 +162,8 @@
"Bash(git commit -m 'Fix: NavDropdown link navigation with stopPropagation *)",
"Bash(git commit -m 'Feat: Remove all filters from products pages *)",
"Bash(git commit -m 'Feat: Add loading spinner for made-to-order page *)",
"Bash(git commit -m 'Revert: Remove loading spinner - was slowing down page *)"
"Bash(git commit -m 'Revert: Remove loading spinner - was slowing down page *)",
"Bash(git commit -m 'Fix: Show approved designs in customer account so they can order *)"
]
}
}
+39
View File
@@ -47,6 +47,12 @@ export default async function AccountPage({ searchParams }: { searchParams: { su
orderBy: { createdAt: 'desc' },
});
const approvedDesigns = await prisma.designApproval.findMany({
where: { customerEmail: customer.email, status: 'APPROVED' },
include: { product: true },
orderBy: { createdAt: 'desc' },
});
// Separate recent (< 7 days) and older (>= 7 days) orders
const now = new Date();
const sevenDaysAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
@@ -121,6 +127,39 @@ export default async function AccountPage({ searchParams }: { searchParams: { su
</div>
)}
<h2 className="mt-10 font-display text-xl">Ready to order</h2>
{approvedDesigns.length === 0 ? (
<p className="mt-3 text-sm text-muted">No approved designs ready to order.</p>
) : (
<div className="mt-4 divide-y divide-line border-t border-line">
{approvedDesigns.map((design) => (
<Link
key={design.id}
href={`/made-to-order/${design.product.slug}?design=${design.id}`}
className="flex items-center gap-4 py-4 hover:bg-surface"
>
<img
src={design.designPreviewUrl}
alt="design preview"
className="h-14 w-14 border border-line object-cover"
/>
<div className="flex-1">
<p className="font-medium">{design.product.name}</p>
<p className="text-sm text-muted">
Approved {new Date(design.createdAt).toLocaleDateString(undefined, { dateStyle: 'medium' })}
</p>
{design.expectedDeliveryDate && (
<p className="text-xs text-muted mt-1">
Est. delivery: {new Date(design.expectedDeliveryDate).toLocaleDateString(undefined, { dateStyle: 'medium' })}
</p>
)}
</div>
<span className="text-sm text-clay">Order </span>
</Link>
))}
</div>
)}
<h2 className="mt-10 font-display text-xl">Order history</h2>
{orders.length === 0 ? (
<p className="mt-3 text-sm text-muted">No orders yet.</p>
+1
View File
@@ -57,6 +57,7 @@ export default function DesignDetailPage({ params }: { params: { id: string } })
if (res.ok) {
const updated = await res.json();
setDesign(updated);
alert(`✓ Design approved! Customer will receive an email with a link to order.${expectedDeliveryDate ? ` Estimated delivery: ${new Date(expectedDeliveryDate).toLocaleDateString()}` : ''}`);
}
} finally {
setApproving(false);