🔧 Fixed Cards Page API Response Format

- 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
This commit is contained in:
Randall Stillwell 2025-07-25 23:16:35 -05:00
parent e41d0b986e
commit d10b70da16
3 changed files with 18 additions and 15 deletions

View file

@ -73,15 +73,7 @@ export default function CollaboratorFacepile({ collectionId, creatorEmail }) {
} }
}; };
console.log('CollaboratorFacepile render:', { // Debug: Log removed - functionality working
collectionId,
creatorEmail,
collaborators: collaborators.length,
allUsers: allUsers.length,
loading,
collaboratorsData: collaborators,
allUsersData: allUsers
});
return ( return (
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">

View file

@ -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) { } catch (error) {
console.error('Error searching cards:', error); console.error('Error searching cards:', error);

View file

@ -299,10 +299,7 @@ export default function CollectionView() {
return acc; return acc;
}, {}); }, {});
// Debug: Log the grouped cards to see what games we have // Debug: Log removed - functionality working
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
// Get game display names and counts - make it more flexible // Get game display names and counts - make it more flexible
const gameStats = {}; const gameStats = {};
@ -399,7 +396,7 @@ export default function CollectionView() {
{/* Creator and Stats */} {/* Creator and Stats */}
<div className="flex items-center space-x-6 text-sm" style={{ color: 'var(--text-secondary)' }}> <div className="flex items-center space-x-6 text-sm" style={{ color: 'var(--text-secondary)' }}>
{console.log('Collection data for facepile:', { id, creator_email: collection.creator_email, collection })}
{collection.creator_email ? ( {collection.creator_email ? (
<CollaboratorFacepile <CollaboratorFacepile
collectionId={id} collectionId={id}