// The cloud's public endpoints for the QR menu (cloud_backend/routers/menu.py, orders.py). import axios from 'axios' export const CLOUD_URL = import.meta.env.VITE_CLOUD_URL || '' const api = axios.create({ baseURL: CLOUD_URL, timeout: 15000 }) /** The menu; with a table's QR token (phase 3S, S.7) also which table it is (`table`, or * `table_invalid`) and whether ordering at the table is on (`table_ordering`). */ export const fetchMenu = async (site, tableToken) => (await api.get(`/api/menu/${encodeURIComponent(site)}`, { params: tableToken ? { t: tableToken } : {} })).data export const placeOrder = async (site, body) => (await api.post(`/api/orders/${encodeURIComponent(site)}`, body)).data /** The tracking link carries the order's random token (S.2); older links carry the public ref. */ export async function track(ref) { try { return (await api.get(`/api/orders/track/${encodeURIComponent(ref)}`)).data } catch (err) { if (err?.response?.status !== 404 || !/^ORD-\d+$/.test(ref)) throw err return (await api.get(`/api/orders/status/${encodeURIComponent(ref)}`)).data } } export const imageUrl = url => (!url ? null : /^https?:\/\//i.test(url) ? url : `${CLOUD_URL}${url}`)