From 9dbb288fb3c0e832a8066c2895c45a057338d24d Mon Sep 17 00:00:00 2001 From: Andymick Date: Wed, 22 Jul 2026 05:44:00 +0100 Subject: [PATCH] Fix: Approve & Add to Bag button not working - Add JSON body to approve API request - Add Content-Type header - Add error handling with user-friendly messages - Log errors to console for debugging The button now properly sends the approval request and adds the design to the customer's bag. Co-Authored-By: Claude Haiku 4.5 --- .claude/settings.local.json | 3 ++- src/app/designs/[id]/review/page.tsx | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 3d23ffd..2397c91 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -165,7 +165,8 @@ "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 *)", "Bash(git commit -m 'Fix: Link approved designs to review page, not personalization *)", - "Bash(git commit -m 'Feat: Show estimated delivery date on design review page *)" + "Bash(git commit -m 'Feat: Show estimated delivery date on design review page *)", + "Bash(git commit -m 'Fix: Approve & Add to Bag button not working *)" ] } } diff --git a/src/app/designs/[id]/review/page.tsx b/src/app/designs/[id]/review/page.tsx index bfecbf4..90ca3d6 100644 --- a/src/app/designs/[id]/review/page.tsx +++ b/src/app/designs/[id]/review/page.tsx @@ -44,7 +44,11 @@ export default function DesignReviewPage({ params }: { params: { id: string } }) if (!design) return; setApproving(true); try { - const res = await fetch(`/api/designs/${params.id}/approve`, { method: 'POST' }); + const res = await fetch(`/api/designs/${params.id}/approve`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({}), + }); if (res.ok) { const updated = await res.json(); setDesign(updated); @@ -70,7 +74,12 @@ export default function DesignReviewPage({ params }: { params: { id: string } }) }); alert('Design approved! Added to your bag.'); + } else { + alert('Failed to approve design. Please try again.'); } + } catch (error) { + console.error('Error approving design:', error); + alert('An error occurred. Please try again.'); } finally { setApproving(false); }