refactors, specific day playtime controls
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getSession } from '@/lib/session';
|
||||
import { db } from '@/lib/db';
|
||||
import { timeSlots } from '@/lib/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const session = await getSession();
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
// Get all active time slots
|
||||
const allTimeSlots = await db
|
||||
.select()
|
||||
.from(timeSlots)
|
||||
.where(eq(timeSlots.isActive, true))
|
||||
.orderBy(timeSlots.dayOfWeek, timeSlots.startTime);
|
||||
|
||||
return NextResponse.json({
|
||||
timeSlots: allTimeSlots,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error fetching time slots:', error);
|
||||
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user