From d10b70da165553b1cb6ba496251d830c1e93a893 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Fri, 25 Jul 2025 23:16:35 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fixed=20Cards=20Page=20API=20Res?= =?UTF-8?q?ponse=20Format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated /api/cards/search to return expected format with success, cards, pagination, and filters - This fixes the empty cards page when clicking 'Add Cards' - Removed debug console logs since TCG tags and CollaboratorFacepile are working - Cards page should now display the sample cards properly --- components/CollaboratorFacepile.js | 10 +--------- pages/api/cards/search.js | 16 +++++++++++++++- pages/collection/[id].js | 7 ++----- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/CollaboratorFacepile.js b/components/CollaboratorFacepile.js index a6e859a..cc4e268 100644 --- a/components/CollaboratorFacepile.js +++ b/components/CollaboratorFacepile.js @@ -73,15 +73,7 @@ export default function CollaboratorFacepile({ collectionId, creatorEmail }) { } }; - console.log('CollaboratorFacepile render:', { - collectionId, - creatorEmail, - collaborators: collaborators.length, - allUsers: allUsers.length, - loading, - collaboratorsData: collaborators, - allUsersData: allUsers - }); + // Debug: Log removed - functionality working return (
diff --git a/pages/api/cards/search.js b/pages/api/cards/search.js index 4767c09..49c44a9 100644 --- a/pages/api/cards/search.js +++ b/pages/api/cards/search.js @@ -39,7 +39,21 @@ export default async function handler(req, res) { `; } - res.status(200).json(result.rows); + res.status(200).json({ + success: true, + cards: result.rows, + pagination: { + page: 1, + limit: parseInt(limit), + total: result.rows.length, + pages: 1 + }, + filters: { + games: [...new Set(result.rows.map(card => card.game).filter(Boolean))], + rarities: [...new Set(result.rows.map(card => card.rarity).filter(Boolean))], + sets: [...new Set(result.rows.map(card => card.set_name).filter(Boolean))] + } + }); } catch (error) { console.error('Error searching cards:', error); diff --git a/pages/collection/[id].js b/pages/collection/[id].js index d8b8107..f5b8638 100644 --- a/pages/collection/[id].js +++ b/pages/collection/[id].js @@ -299,10 +299,7 @@ export default function CollectionView() { return acc; }, {}); - // Debug: Log the grouped cards to see what games we have - console.log('Grouped cards:', groupedCards); - console.log('Available games:', Object.keys(groupedCards)); - console.log('Sample card data:', cards[0]); // Check what fields the card actually has + // Debug: Log removed - functionality working // Get game display names and counts - make it more flexible const gameStats = {}; @@ -399,7 +396,7 @@ export default function CollectionView() { {/* Creator and Stats */}
- {console.log('Collection data for facepile:', { id, creator_email: collection.creator_email, collection })} + {collection.creator_email ? (