How it works
GPS geofencing detection
The app uses the Haversine formula to calculate the distance between the user’s GPS coordinates and the restaurant location:If the distance is ≤ 50 meters, the app switches to
src/components/location/ContextSwitcher.tsx
SCANNER mode.QR code scanning
The camera activates and displays a branded overlay with an animated scan frame. See QR Scanner for details.
Table session initialization
When a valid QR code is scanned, the app:
- Validates the table ID against the
TABLES_DATAregistry (src/lib/core/mockData.ts:9) - Stores the active table in
useTableStore(src/stores/useTableStore.ts:10) - Triggers multimodal feedback (haptic + sound)
- Navigates to the menu screen
Contextual menu display
The menu filters products based on the table’s
menuType. See Contextual Menus for details.Table types
Tables are configured with amenuType property that determines which products are visible:
State management
Table mode uses three Zustand stores:Location store
src/stores/useLocationStore.ts
Table store
Manages the active table session:Cart store
Handles orders and birthday discounts:src/stores/useCartStore.ts
The birthday discount is applied immediately when the table is scanned (src/lib/modules/menu/useMenuLogic.ts:22), not at checkout.
QR code format
Table QR codes must match the formatTABLE_* to be recognized. Test codes:
| QR Code | Table | Menu Type | Special Event |
|---|---|---|---|
TABLE_BAR_01 | Barra 01 | Drinks only | None |
TABLE_HALL_05 | Salon 05 | Full menu | None |
TABLE_BDAY_99 | Mesa Especial | Full menu | Birthday (15% off) |
Session lifecycle
The session is cleared after successful payment (src/app/(checkout)/payment.tsx:252):Related features
QR Scanner
Camera-based QR code scanning with idempotency guards
Contextual Menus
Dynamic menu filtering by table type
Payments
Checkout flow and payment processing
Delivery Mode
Alternative mode for customers outside the geofence