feat(menu-app): the QR menu on the customer apps' look, two languages, allergens (platform-v2 step 6.5)
- 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>
This commit is contained in:
@@ -1,30 +1,21 @@
|
||||
// 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 })
|
||||
|
||||
const api = axios.create({ baseURL: CLOUD_URL })
|
||||
|
||||
/** The menu; with a table's QR token (phase 3S, S.7) it also says which table it is
|
||||
* (`table`, or `table_invalid`) and whether ordering at the table is on (`table_ordering`). */
|
||||
export async function fetchMenu(siteSlug, tableToken) {
|
||||
const { data } = await api.get(`/api/menu/${siteSlug}`, { params: tableToken ? { t: tableToken } : {} })
|
||||
return data
|
||||
}
|
||||
|
||||
export async function submitOrder(siteSlug, body) {
|
||||
const { data } = await api.post(`/api/orders/${siteSlug}`, body)
|
||||
return data // { order_id, public_ref, status }
|
||||
}
|
||||
|
||||
// The tracking link carries the order's random token (phase 3S, S.2); links from before that
|
||||
// carry the public ref and use the old endpoint.
|
||||
export async function fetchOrderStatus(ref) {
|
||||
/** 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 {
|
||||
const { data } = await api.get(`/api/orders/track/${ref}`)
|
||||
return data // { public_ref, status, rejection_reason }
|
||||
return (await api.get(`/api/orders/track/${encodeURIComponent(ref)}`)).data
|
||||
} catch (err) {
|
||||
if (err?.response?.status !== 404 || !/^ORD-\d+$/.test(ref)) throw err
|
||||
const { data } = await api.get(`/api/orders/status/${ref}`)
|
||||
return data
|
||||
return (await api.get(`/api/orders/status/${encodeURIComponent(ref)}`)).data
|
||||
}
|
||||
}
|
||||
export const imageUrl = url => (!url ? null : /^https?:\/\//i.test(url) ? url : `${CLOUD_URL}${url}`)
|
||||
|
||||
Reference in New Issue
Block a user