Backend (FastAPI + Python 3.12): - Multi-tenant auth with JWT: login, register, refresh, Meta OAuth - Business & BusinessConfig management - WhatsApp webhook with HMAC signature verification - Bot engine powered by Claude AI - Calendar availability with Redis caching - Reservations CRUD with status management - Dashboard analytics (stats, agenda, peak hours) - Billing & plan management - Admin panel with platform-wide stats - Async bcrypt via asyncio.to_thread - IntegrityError handling for concurrent registration race conditions Frontend (React 18 + Vite + Tailwind CSS): - Multi-step guided registration form with helper text on every field - Login page with show/hide password toggle - Protected routes with AuthContext - Dashboard with stats cards, bar chart, and daily agenda - Reservations list with search, filters, and inline status actions - Calendar with weekly view, slot availability, and date blocking - Config page: business info, schedules, bot personality - Billing page with plan comparison and usage bar Design system: - Bricolage Grotesque + DM Sans typography - Emerald primary palette with semantic color tokens - scale(0.97) button press feedback, ease-out animations - Skeleton loaders, stagger animations, prefers-reduced-motion support - Accessible: aria-labels, visible focus rings, 4.5:1 contrast Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
from datetime import date
|
|
|
|
import redis.asyncio as aioredis
|
|
from fastapi import APIRouter, Depends, Response
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.core.database import get_db
|
|
from app.core.dependencies import get_current_business
|
|
from app.core.redis import get_redis
|
|
from app.modules.calendar import schemas, service
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/availability", response_model=schemas.DayAvailability)
|
|
async def get_availability(
|
|
date: date,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
return await service.get_available_slots(db, redis, business_id, date)
|
|
|
|
|
|
@router.get("/availability/range", response_model=list[schemas.DayAvailability])
|
|
async def get_availability_range(
|
|
start: date,
|
|
end: date,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
return await service.get_availability_range(db, redis, business_id, start, end)
|
|
|
|
|
|
@router.post("/blocked-dates", status_code=201)
|
|
async def add_blocked_date(
|
|
body: schemas.BlockedDateRequest,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
await service.add_blocked_date(db, business_id, body.date)
|
|
await service.invalidate_slots_cache(redis, business_id, body.date)
|
|
return {"detail": "Fecha bloqueada"}
|
|
|
|
|
|
@router.delete("/blocked-dates/{target_date}", status_code=204)
|
|
async def remove_blocked_date(
|
|
target_date: date,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
await service.remove_blocked_date(db, business_id, target_date)
|
|
await service.invalidate_slots_cache(redis, business_id, target_date)
|
|
return Response(status_code=204)
|