venues and ui changes

This commit is contained in:
2025-07-24 09:42:57 -04:00
parent 049def6886
commit 27590f9509
24 changed files with 757 additions and 164 deletions

View File

@@ -0,0 +1,47 @@
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/app/api/auth/[...nextauth]/route'
export async function GET(
req: NextRequest,
{ params }: { params: { eventId: string } }
) {
const session = await getServerSession(authOptions)
if (!session?.user) {
return NextResponse.json({ message: 'Unauthorized' }, { status: 401 })
}
try {
const event = await prisma.event.findUnique({
where: { id: params.eventId },
include: {
creator: {
select: { id: true, name: true, email: true, role: true }
},
venue: true,
todos: {
orderBy: [
{ complete: 'asc' },
{ dueDate: 'asc' }
]
},
eventGuests: {
include: {
guestBookEntry: true
}
}
}
})
if (!event) {
return NextResponse.json({ message: 'Event not found' }, { status: 404 })
}
return NextResponse.json(event)
} catch (err) {
console.error(err)
return NextResponse.json({ message: 'Error fetching event' }, { status: 500 })
}
}

View File

@@ -1,27 +1,29 @@
import { NextRequest, NextResponse } from 'next/server';
import { mutations } from '@/lib/mutations';
import { getServerSession } from 'next-auth';
import { authOptions } from '../../auth/[...nextauth]/route';
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/app/api/auth/[...nextauth]/route'
export async function PATCH(req: NextRequest, { params }: { params: { eventId: string } }) {
const session = await getServerSession(authOptions);
const session = await getServerSession(authOptions)
if (!session?.user) {
return new NextResponse('Unauthorized', { status: 401 });
return NextResponse.json({ message: 'Unauthorized' }, { status: 401 })
}
const eventId = params.eventId;
const body = await req.json();
const body = await req.json()
try {
const updated = await mutations.updateEvent(eventId, {
name: body.name,
date: body.date,
location: body.location,
notes: body.notes,
});
return NextResponse.json(updated);
} catch (error) {
console.error('[PATCH EVENT]', error);
return new NextResponse('Failed to update event', { status: 500 });
const updated = await prisma.event.update({
where: { id: params.eventId },
data: {
name: body.name,
date: body.date ? new Date(body.date) : undefined,
venueId: body.venueId || null,
},
})
return NextResponse.json(updated)
} catch (err) {
console.error(err)
return NextResponse.json({ message: 'Error updating event' }, { status: 500 })
}
}