Files
Marco Gallegos d27354fd5a feat: Add kiosk management, artist selection, and schedule management
- Add KiosksManagement component with full CRUD for kiosks
- Add ScheduleManagement for staff schedules with break reminders
- Update booking flow to allow artist selection by customers
- Add staff_services API for assigning services to artists
- Update staff management UI with service assignment dialog
- Add auto-break reminder when schedule >= 8 hours
- Update availability API to filter artists by service
- Add kiosk management to Aperture dashboard
- Clean up ralphy artifacts and logs
2026-01-21 13:02:06 -06:00

70 lines
2.5 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { supabase } from '@/lib/supabase/client'
/**
* @description Public API endpoint providing basic location and service information for booking availability overview
* @param {NextRequest} request - HTTP request with required query parameter: location_id
* @returns {NextResponse} JSON with location details and list of active services, plus guidance to detailed availability endpoint
* @example GET /api/public/availability?location_id=123e4567-e89b-12d3-a456-426614174000
* @audit BUSINESS RULE: Provides high-level availability info; detailed time slots available via /api/availability/time-slots
* @audit SECURITY: Public endpoint; no authentication required; returns only active locations and services
* @audit Validate: Ensures location_id is provided and location is active
* @audit PERFORMANCE: Single query fetches location and services with indexed lookups
* @audit AUDIT: High-volume public endpoint; consider rate limiting in production
*/
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url)
const locationId = searchParams.get('location_id')
if (!locationId) {
return NextResponse.json(
{ error: 'Missing required parameter: location_id' },
{ status: 400 }
)
}
// Get location details
const { data: location, error: locationError } = await supabase
.from('locations')
.select('id, name, timezone')
.eq('id', locationId)
.eq('is_active', true)
.single()
if (locationError || !location) {
return NextResponse.json(
{ error: 'Location not found' },
{ status: 404 }
)
}
// Get active services for this location
const { data: services, error: servicesError } = await supabase
.from('services')
.select('id, name, duration_minutes, base_price')
.eq('is_active', true)
.order('name', { ascending: true })
if (servicesError) {
console.error('Public availability services error:', servicesError)
return NextResponse.json(
{ error: servicesError.message },
{ status: 500 }
)
}
return NextResponse.json({
success: true,
location,
services: services || [],
note: 'Use /api/availability/time-slots for detailed availability'
})
} catch (error) {
console.error('Public availability GET error:', error)
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
)
}
}