mirror of
https://github.com/marcogll/AnchorOS.git
synced 2026-03-15 16:24:30 +00:00
feat: Implementar base de Aperture (aperture.anchor23.mx)
**Aperture - Backend para staff/manager/admin:**
- Crear página principal de admin (/aperture)
- Dashboard con estadísticas del día (citas, ingresos, pendientes)
- Navegación por tabs (Dashboard, Staff, Recursos, Reportes)
- Diseño limpio con métricas y cards
- Crear APIs administrativas:
- /api/aperture/staff - Staff disponible por ubicación
- /api/aperture/staff/schedule - CRUD de horarios de staff
- GET: Listar horarios con filtros
- POST: Crear bloqueo de horario
- DELETE: Eliminar horario
- /api/aperture/resources - Recursos por ubicación
- /api/aperture/dashboard - Bookings por fecha y staff
**The Boutique - Mejoras:**
- Página de confirmación por código (/booking/confirmacion)
- Verificación por short_id
- Detalles completos de cita
- Información sobre políticas
- Layout personalizado con navbar específico
**TASKS.md - Actualización:**
- Aperture marcado como 'En Progreso' con APIs implementadas
- The Boutique actualizado con página de confirmación
- Reorganización de tareas prioritarias
- Estado del proyecto actualizado (Fase 2: 30%)
**Arquitectura:**
- Separación clara: anchor23.mx (marketing), booking (cliente), aperture (operaciones)
- APIs RESTful para gestión administrativa
- Dashboard responsive con métricas operativas
This commit is contained in:
88
app/api/aperture/dashboard/route.ts
Normal file
88
app/api/aperture/dashboard/route.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { supabaseAdmin } from '@/lib/supabase/client'
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const locationId = searchParams.get('location_id')
|
||||
const startDate = searchParams.get('start_date')
|
||||
const endDate = searchParams.get('end_date')
|
||||
const staffId = searchParams.get('staff_id')
|
||||
const status = searchParams.get('status')
|
||||
|
||||
let query = supabaseAdmin
|
||||
.from('bookings')
|
||||
.select(`
|
||||
id,
|
||||
short_id,
|
||||
status,
|
||||
start_time_utc,
|
||||
end_time_utc,
|
||||
is_paid,
|
||||
created_at,
|
||||
customer (
|
||||
id,
|
||||
first_name,
|
||||
last_name,
|
||||
email
|
||||
),
|
||||
service (
|
||||
id,
|
||||
name,
|
||||
duration_minutes,
|
||||
base_price
|
||||
),
|
||||
staff (
|
||||
id,
|
||||
display_name
|
||||
),
|
||||
resource (
|
||||
id,
|
||||
name,
|
||||
type
|
||||
)
|
||||
`)
|
||||
.order('start_time_utc', { ascending: true })
|
||||
|
||||
if (locationId) {
|
||||
query = query.eq('location_id', locationId)
|
||||
}
|
||||
|
||||
if (startDate) {
|
||||
query = query.gte('start_time_utc', startDate)
|
||||
}
|
||||
|
||||
if (endDate) {
|
||||
query = query.lte('end_time_utc', endDate)
|
||||
}
|
||||
|
||||
if (staffId) {
|
||||
query = query.eq('staff_id', staffId)
|
||||
}
|
||||
|
||||
if (status) {
|
||||
query = query.in('status', status.split(','))
|
||||
}
|
||||
|
||||
const { data: bookings, error } = await query
|
||||
|
||||
if (error) {
|
||||
console.error('Aperture dashboard GET error:', error)
|
||||
return NextResponse.json(
|
||||
{ error: error.message },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
bookings: bookings || []
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Aperture dashboard GET error:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Internal server error' },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user