deckhearth/pages/api/cards/[id]/decks.js
Randall Stillwell bb60b4f6b0 Enhanced card detail page with real data and functionality
- Updated card detail page to fetch real data from API
- Added ownership tracking with quantity management
- Added favorite system for cards
- Added collection and deck management functionality
- Created API endpoints for ownership, favorites, collections, and decks
- Added database columns for quantity and favorited status
- Shows current collections and decks the card belongs to
- Added proper error handling and loading states
- Integrated with real card data from database
- Added purchase links to TCGPlayer and eBay
2025-07-24 15:03:09 -05:00

35 lines
No EOL
1 KiB
JavaScript

import { sql } from '@vercel/postgres';
export default async function handler(req, res) {
const { id } = req.query;
if (req.method === 'GET') {
try {
// For now, return mock data until we implement the decks table
const mockCardDecks = [
{ id: 1, name: 'MTG Control Deck' },
{ id: 4, name: 'MTG Combo' }
];
res.status(200).json(mockCardDecks);
} catch (error) {
console.error('Error fetching card decks:', error);
res.status(500).json({ error: 'Failed to fetch card decks' });
}
} else if (req.method === 'POST') {
try {
const { deckId } = req.body;
// For now, just return success until we implement the decks table
res.status(200).json({
success: true,
message: 'Card added to deck'
});
} catch (error) {
console.error('Error adding card to deck:', error);
res.status(500).json({ error: 'Failed to add card to deck' });
}
} else {
res.status(405).json({ error: 'Method not allowed' });
}
}