Commit Graph

3 Commits

Author SHA1 Message Date
Marco Gallegos
f6832c1e29 fix: Improve API initialization with lazy Supabase client and validation
- Move Supabase/Stripe initialization inside GET/POST handlers for lazy loading
- Add validation for missing environment variables in runtime
- Improve error handling in payment intent creation
- Clean up next.config.js environment variable configuration

This fixes potential build-time failures when environment variables are not available
during static generation.
2026-01-18 22:51:45 -06:00
Marco Gallegos
d1735878ef fix: Build Docker image, fix SelectItem empty values, add admin seed script
- Add placeholder env vars for Supabase, Stripe, and Resend in Dockerfile
- Fix empty SelectItem values in POS and payroll forms
- Fix missing Supabase env variables in stats route
- Create seed-admin-users.sql script for Frida Lara, América de la Cruz, and Alejandra Ponce as admin users
- Docker image marcogll/anchoros:test built and pushed successfully
2026-01-17 23:41:45 -06:00
Marco Gallegos
e33a9a4573 feat(critical): Implement critical Aperture features
TASK 1: Implement GET /api/aperture/stats
- Create endpoint at app/api/aperture/stats/route.ts
- Returns dashboard statistics: { totalBookings, totalRevenue, completedToday, upcomingToday }
- Calculates stats from bookings table by month and today
- Dashboard now has functional statistics display

TASK 2: Implement authentication for Aperture
- Create middleware.ts for protecting Aperture routes
- Only allows access to users with admin, manager, or staff roles
- Redirects unauthorized users to /aperture/login
- Uses Supabase Auth with session verification
- Integrates with existing AuthProvider in lib/auth/context.tsx

Stack Updates:
- Update @supabase/auth-helpers-nextjs to latest version (0.15.0)
- Note: Package marked as deprecated but still functional

Files Created:
- app/api/aperture/stats/route.ts
- middleware.ts

Files Modified:
- TASKS.md (marked tasks 1 and 2 as completed)
- package.json (updated dependency)

Impact:
- Aperture dashboard now has working statistics
- Aperture routes are now protected by authentication
- Only authorized staff/admin/manager can access dashboard

Next: Task 3 - Implement weekly invitation reset
2026-01-17 10:48:40 -06:00