From 0f119b5db5a17a0ad32e351d042b175d1f45fe9e Mon Sep 17 00:00:00 2001 From: Andymick Date: Wed, 22 Jul 2026 05:38:51 +0100 Subject: [PATCH] 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 --- .claude/settings.local.json | 3 ++- src/app/account/page.tsx | 39 +++++++++++++++++++++++++++++ src/app/admin/designs/[id]/page.tsx | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index e4ca634..2747beb 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -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 *)" ] } } diff --git a/src/app/account/page.tsx b/src/app/account/page.tsx index c20c115..ac9bcb2 100644 --- a/src/app/account/page.tsx +++ b/src/app/account/page.tsx @@ -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 )} +

Ready to order

+ {approvedDesigns.length === 0 ? ( +

No approved designs ready to order.

+ ) : ( +
+ {approvedDesigns.map((design) => ( + + design preview +
+

{design.product.name}

+

+ Approved {new Date(design.createdAt).toLocaleDateString(undefined, { dateStyle: 'medium' })} +

+ {design.expectedDeliveryDate && ( +

+ Est. delivery: {new Date(design.expectedDeliveryDate).toLocaleDateString(undefined, { dateStyle: 'medium' })} +

+ )} +
+ Order → + + ))} +
+ )} +

Order history

{orders.length === 0 ? (

No orders yet.

diff --git a/src/app/admin/designs/[id]/page.tsx b/src/app/admin/designs/[id]/page.tsx index 410fc45..311a893 100644 --- a/src/app/admin/designs/[id]/page.tsx +++ b/src/app/admin/designs/[id]/page.tsx @@ -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);