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>
75 lines
2.5 KiB
Python
75 lines
2.5 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.reservations import schemas, service
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/", response_model=list[schemas.ReservationRead])
|
|
async def list_reservations(
|
|
date: date | None = None,
|
|
status: str | None = None,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
return await service.list_reservations(db, business_id, date, status)
|
|
|
|
|
|
@router.post("/", response_model=schemas.ReservationRead, status_code=201)
|
|
async def create_reservation(
|
|
body: schemas.ReservationCreate,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
return await service.create_reservation(db, redis, business_id, body)
|
|
|
|
|
|
@router.get("/{reservation_id}", response_model=schemas.ReservationRead)
|
|
async def get_reservation(
|
|
reservation_id: int,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
return await service.get_reservation(db, business_id, reservation_id)
|
|
|
|
|
|
@router.put("/{reservation_id}", response_model=schemas.ReservationRead)
|
|
async def update_reservation(
|
|
reservation_id: int,
|
|
body: schemas.ReservationUpdate,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
return await service.update_reservation(db, redis, business_id, reservation_id, body)
|
|
|
|
|
|
@router.delete("/{reservation_id}", status_code=204)
|
|
async def delete_reservation(
|
|
reservation_id: int,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
await service.delete_reservation(db, redis, business_id, reservation_id)
|
|
return Response(status_code=204)
|
|
|
|
|
|
@router.patch("/{reservation_id}/status", response_model=schemas.ReservationRead)
|
|
async def update_status(
|
|
reservation_id: int,
|
|
body: schemas.StatusUpdate,
|
|
business_id: int = Depends(get_current_business),
|
|
db: AsyncSession = Depends(get_db),
|
|
redis: aioredis.Redis = Depends(get_redis),
|
|
):
|
|
return await service.update_status(db, redis, business_id, reservation_id, body.status)
|