35 lines
1 KiB
JavaScript
35 lines
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' });
|
||
|
|
}
|
||
|
|
}
|