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 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-22 05:44:00 +01:00
co-authored by Claude Haiku 4.5
parent bdb5955447
commit 9dbb288fb3
2 changed files with 12 additions and 2 deletions
+2 -1
View File
@@ -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 *)"
]
}
}
+10 -1
View File
@@ -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);
}