import { NextRequest, NextResponse } from 'next/server' import { prisma } from '@/lib/prisma' import { getSession } from '@/lib/auth-simple' export async function GET() { const session = await getSession() if (!session) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) } const settings = await (prisma as any).clubSettings.findFirst() return NextResponse.json(settings) } export async function PATCH(request: NextRequest) { const session = await getSession() if (!session) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) } const data = await request.json() // Get the existing settings record (should be id: 1 or first record) let settings = await (prisma as any).clubSettings.findFirst() if (!settings) { // Create default settings if none exist settings = await (prisma as any).clubSettings.create({ data: { clubName: 'Euchre Club', defaultEloRating: 1200, partnershipEnabled: true, notificationsEnabled: true, matchVerification: false, }, }) } // Update the settings const updatedSettings = await (prisma as any).clubSettings.update({ where: { id: settings.id }, data, }) return NextResponse.json(updatedSettings) }