Skip to main content
TableOrder uses TypeScript for type safety across the application. All core type definitions are located in /src/lib/core/types.ts.

Table domain

Types for restaurant table management and status.

TableStatus

type TableStatus = 'FREE' | 'OCCUPIED' | 'PAYING';
Represents the current state of a table:
FREE
string
Table is available and ready for new customers
OCCUPIED
string
Table is currently in use by customers
PAYING
string
Table is in the payment/checkout process
type MenuType = 'FULL' | 'DRINKS_ONLY';
Defines the type of menu available at a table:
FULL
string
Full menu with food, drinks, snacks, and desserts
DRINKS_ONLY
string
Limited menu with beverages only

SpecialEvent

type SpecialEvent = 'NONE' | 'BIRTHDAY';
Indicates if a table has a special event:
NONE
string
No special event for this table
BIRTHDAY
string
Birthday celebration (triggers discount and special UI)

TableData

interface TableData {
  id: string;
  displayName: string;
  status: TableStatus;
  menuType: MenuType;
  specialEvent: SpecialEvent;
  discount?: number;
  animation?: 'cake';
}
Complete table information structure:
id
string
required
Unique identifier for the table (e.g., "TABLE_01")
displayName
string
required
Human-readable table name (e.g., "Mesa 1")
status
TableStatus
required
Current table status (FREE, OCCUPIED, or PAYING)
menuType
MenuType
required
Available menu type (FULL or DRINKS_ONLY)
specialEvent
SpecialEvent
required
Special event type (NONE or BIRTHDAY)
discount
number
Discount amount as a decimal (e.g., 0.15 for 15% off). Only present for birthday tables.
animation
'cake'
Animation identifier for special events. Currently only supports 'cake'.

Types for product catalog and menu items.

ProductCategory

type ProductCategory = 'FOOD' | 'DRINK' | 'SNACK' | 'DESSERT';
Product classification:
FOOD
string
Main dishes and entrees
DRINK
string
Beverages (alcoholic and non-alcoholic)
SNACK
string
Appetizers and small bites
DESSERT
string
Sweet treats and desserts

Product

interface Product {
  id: string;
  name: string;
  price: number;
  category: ProductCategory;
  image: string;
  description?: string;
}
Product information:
id
string
required
Unique product identifier
name
string
required
Product name displayed to customers
price
number
required
Product price in the base currency unit (e.g., dollars/euros)
category
ProductCategory
required
Product category for filtering and organization
image
string
required
Path or URL to product image
description
string
Detailed product description or ingredients list

Cart domain

Types for shopping cart and order management.

CartItem

interface CartItem {
  product: Product;
  quantity: number;
}
Represents a product in the shopping cart:
product
Product
required
Full product object with all details
quantity
number
required
Number of units of this product in the cart

Location and context-aware domain

Types for GPS-based context switching and delivery routing.

AppMode

type AppMode = 'CHECKING' | 'SCANNER' | 'DELIVERY';
Application context mode determined by GPS-based geofencing:
CHECKING
string
Initial state while determining user location and proximity
SCANNER
string
In-situ mode for customers inside the restaurant. Activates QR code scanner for table selection.
DELIVERY
string
Delivery mode for customers outside the geofence radius. Shows delivery menu and routing.

Coordinates

interface Coordinates {
  latitude: number;
  longitude: number;
}
WGS-84 geographic coordinates:
latitude
number
required
Latitude in decimal degrees (range: -90 to 90)
longitude
number
required
Longitude in decimal degrees (range: -180 to 180)

DeliveryInfo

interface DeliveryInfo {
  distanceKm: number;
  etaMinutes: number;
  polyline: string;
  decodedRoute: Coordinates[];
}
Decoded Mapbox Directions route metadata:
distanceKm
number
required
Total delivery distance in kilometers
etaMinutes
number
required
Estimated time of arrival in minutes
polyline
string
required
Encoded polyline string from Mapbox API (RFC 1952 encoded geometry)
decodedRoute
Coordinates[]
required
Decoded array of coordinates ready for rendering with react-native-maps <Polyline /> component

Usage examples

Table data

import { TableData } from '@/src/lib/core/types';

const birthdayTable: TableData = {
  id: 'TABLE_01',
  displayName: 'Mesa 1',
  status: 'OCCUPIED',
  menuType: 'FULL',
  specialEvent: 'BIRTHDAY',
  discount: 0.15,
  animation: 'cake',
};

Product catalog

import { Product } from '@/src/lib/core/types';

const pizza: Product = {
  id: 'FOOD_001',
  name: 'Pizza Margherita',
  price: 12.99,
  category: 'FOOD',
  image: '/images/pizza.jpg',
  description: 'Classic tomato, mozzarella, and basil',
};

Cart management

import { CartItem } from '@/src/lib/core/types';

const cartItem: CartItem = {
  product: pizza,
  quantity: 2,
};

GPS coordinates

import { Coordinates, calculateDistance } from '@/src/lib/core/types';

const userLocation: Coordinates = {
  latitude: 40.7128,
  longitude: -74.0060,
};

const restaurantLocation: Coordinates = {
  latitude: 40.7589,
  longitude: -73.9851,
};

Delivery routing

import { DeliveryInfo } from '@/src/lib/core/types';

const deliveryRoute: DeliveryInfo = {
  distanceKm: 3.2,
  etaMinutes: 15,
  polyline: 'encoded_polyline_string...',
  decodedRoute: [
    { latitude: 40.7128, longitude: -74.0060 },
    { latitude: 40.7589, longitude: -73.9851 },
  ],
};