import { NextResponse } from 'next/server'; import { getAvailableSlots } from '@/lib/server/booking'; export const dynamic = 'force-dynamic'; /** * GET /api/availability?serviceId=&staffId=&date= * Server-computed bookable slots (past and taken slots already excluded). All datetimes are UTC * ISO strings; `timeZone` tells the client how to display them. */ export async function GET(request: Request) { const { searchParams } = new URL(request.url); const serviceId = searchParams.get('serviceId'); const staffId = searchParams.get('staffId') || null; const date = searchParams.get('date') || undefined; if (!serviceId) return NextResponse.json({ error: 'serviceId is required.' }, { status: 400 }); const result = await getAvailableSlots({ serviceId, staffId, date }); if (!result) return NextResponse.json({ error: 'Service not found.' }, { status: 404 }); return NextResponse.json(result); }