- connect_frontend/menu-app rebuilt like the order app: the same tokens (index.css, tailwind.config.js), texts in i18n.js (en, el; the old 'ot_lang' choice carries over), pure logic in src/logic.js with tests (menuFor in the guest's language, QR prices, search in either language, cart, order body, refusals). MenuPage (menu, search, dish sheet, cart, checkout at the table) and ConfirmPage; App.jsx, components/primitives and OrderConfirm removed; react-hot-toast dropped. - Allergens on every dish (contains on the card; contains / may contain on the dish sheet) and in the order app's cards too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
22 lines
1.2 KiB
JavaScript
22 lines
1.2 KiB
JavaScript
// 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}`)
|