feat: Implementar API de reservas para clientes

- Crear route /api/bookings con POST y GET
- Validar disponibilidad de staff y recursos
- Crear cliente si no existe
- Generar short_id para reservas
- Utilizar RPC functions de disponibilidad
- Agregar utilidad generateShortId
This commit is contained in:
Marco Gallegos
2026-01-16 15:17:01 -06:00
parent 392621e2cc
commit 8d33778779
2 changed files with 325 additions and 0 deletions

11
lib/utils/short-id.ts Normal file
View File

@@ -0,0 +1,11 @@
import { supabaseAdmin } from '@/lib/supabase/client'
export async function generateShortId(): Promise<string> {
const { data, error } = await supabaseAdmin.rpc('generate_short_id')
if (error) {
throw new Error(`Failed to generate short_id: ${error.message}`)
}
return data as string
}