diff --git a/docs/README.md b/docs/README.md index f140008..ee0f424 100644 --- a/docs/README.md +++ b/docs/README.md @@ -45,6 +45,7 @@ The manager calls the API **same-origin, with relative paths**. The waiter app r | `local_backend/services/system_products.py`, `services/online_check.py` | Lines the system adds itself (phase 3S): the delivery fee is an order line whose product has `system_key` and `lifecycle_status = "system"` (never on a menu or in the catalogue, never added by hand, added printed + served so the kitchen never sees it; paid, counted, receipted and refunded like any line). The site's own price check of a pulled online order (`orders.online_price_diff`): shown, never applied — the customer pays the cloud's prices | | `local_backend/services/online_reservations.py` | Table bookings from the online ordering app (phase 3S): stored as `Reservation` rows (`requested` → `pending` confirmed / `declined`; `arrived`, `cancelled`, `no_show`), food ordered ahead kept on the booking (`items_json`) and turned into an order **only at the fire time** (`fire_worker`, a connect_orders module worker; needs an open business day) or on early arrival. Every step mirrors the cloud status. The counter's Online → Bookings and `/api/connect/bookings/*` use it; the reservations router delegates online bookings to it | | `local_backend/services/table_qr.py`, `services/qr_orders.py` | The QR menu at the table (phase 3S): every active table has a random `qr_token`; the menu snapshot carries only its sha256 (`qr`), so the cloud can check a code but never make one. A new code (rotate) kills the printed one at the next push (`/api/tables` and `/api/connect/qr` are in `MENU_PATHS`). A QR order with a valid table goes straight onto the table's open order (or a new one), to the kitchen, with a `qr_order` message to the table's waiters; the audit row `QR_ORDER` (note = the cloud ref) keeps repeats out. Manager page `/online/qr` | +| `local_backend/routers/fees.py` | The venue's online ordering settings (`connect_orders.ordering`: services, hours, slots, ASAP; `reservations`: bookings, food ahead, fire minutes), delivery areas and fee rules, the fee line's name/VAT, and the venue's links (`links.order`, `links.menu` from the cloud's `apps_url`). Everything here travels to the cloud in the menu snapshot (contract C-2) | | `local_backend/routers/ws.py` | Real-time event stream (seq + cursor replay) | | `waiter_pwa/src/config/server.js` | **Where the backend is**: active venue, `apiBase()`, `wsUrl()`, `assetUrl()`, `storageKey()`, `dbName()`, `deliveryMode()` | | `waiter_pwa/android/`, `capacitor.config.json` | Native Android app (Capacitor 8). See "Native Android app" below | diff --git a/local_backend/routers/fees.py b/local_backend/routers/fees.py index fbc5f76..db41cb8 100644 --- a/local_backend/routers/fees.py +++ b/local_backend/routers/fees.py @@ -247,8 +247,12 @@ def list_fees(db: Session = Depends(get_db), user=Depends(require(KEY))): from services import system_products fee_product = system_products.get(db, system_products.DELIVERY_FEE) db.commit() + from config import settings + from services.table_qr import apps_url, menu_url return {**fees_payload(db), "ordering": ordering_settings(db), - "fee_product": {**system_products.out(fee_product), "vat_groups": _vat_groups(db)}} + "fee_product": {**system_products.out(fee_product), "vat_groups": _vat_groups(db)}, + # the venue's ordering link (S.99): to share, print or put on the website + "links": {"order": f"{apps_url()}/order/{settings.SITE_ID or ''}", "menu": menu_url()}} def _vat_groups(db) -> list[dict]: diff --git a/local_backend/tests/test_online_site_side.py b/local_backend/tests/test_online_site_side.py index c296e3e..a11304c 100644 --- a/local_backend/tests/test_online_site_side.py +++ b/local_backend/tests/test_online_site_side.py @@ -168,3 +168,11 @@ def test_kitchen_ticket_shows_the_reference_and_the_time(db, menu): assert _place(order, "None") == "ORD-0605" order.requested_for = None assert _online_meta(order)[1] == ("For:", "As soon as possible") + + +def test_the_venues_ordering_link(client, owner_h, monkeypatch): + from services import cloud_sync + monkeypatch.setitem(cloud_sync.license_state, "apps_url", "https://menu.example.com") + monkeypatch.setattr(cloud_sync.settings, "SITE_ID", "taverna-1") + links = client.get("/api/connect/fees", headers=owner_h).json()["links"] + assert links == {"order": "https://menu.example.com/order/taverna-1", "menu": "https://menu.example.com/menu/taverna-1"} diff --git a/manager_dashboard/src/pages/online/FeesPage.jsx b/manager_dashboard/src/pages/online/FeesPage.jsx index 3b491ae..933eb3f 100644 --- a/manager_dashboard/src/pages/online/FeesPage.jsx +++ b/manager_dashboard/src/pages/online/FeesPage.jsx @@ -14,6 +14,7 @@ import { SALES_POINTS } from '@xenia/access' import { Button, Dialog, EmptyState, Field, IconButton, Input, Select, Spinner, Switch } from '@xenia/ui' import client from '../../api/client' import FeeProductCard from './FeeProductCard' +import OrderingLink from './OrderingLink' import OrderingSettings from './OrderingSettings' import { ACTIONS, DAYS, describeRule, emptyRule, moveRule, parsePostcodes, previewBody, ruleBody, ruleProblems, ruleToForm } from './feesLogic' @@ -57,6 +58,8 @@ export default function FeesPage() {

{t('ordering.pageTitle')}

+ {data.links?.order && } +
diff --git a/manager_dashboard/src/pages/online/OrderingLink.jsx b/manager_dashboard/src/pages/online/OrderingLink.jsx new file mode 100644 index 0000000..9354048 --- /dev/null +++ b/manager_dashboard/src/pages/online/OrderingLink.jsx @@ -0,0 +1,31 @@ +// The venue's online ordering link (plan phase 3S, wrap-up): the address of its ordering app +// (takeaway, delivery, table bookings) to share, put on the website or social pages, or print +// as a QR code for flyers and the shop window. GET /api/connect/fees → links.order (the cloud +// tells the venue where the customer apps live: PUBLIC_APPS_URL, sent with the heartbeat). +import toast from 'react-hot-toast' +import { QRCodeSVG } from 'qrcode.react' +import { Copy, ExternalLink, Printer } from 'lucide-react' +import { useTranslation } from '@xenia/i18n' +import { Button } from '@xenia/ui' + +export default function OrderingLink({ url }) { + const { t } = useTranslation('manager') + const copy = async () => { + try { await navigator.clipboard.writeText(url); toast.success(t('orderingLink.copied')) } catch { toast.error(url) } + } + return ( +
+
+
+ +

{t('orderingLink.intro')}

+ {url} +
+ + + +
+
+
+ ) +} diff --git a/packages/i18n/locales/el/manager.json b/packages/i18n/locales/el/manager.json index 4c2660f..70f2933 100644 --- a/packages/i18n/locales/el/manager.json +++ b/packages/i18n/locales/el/manager.json @@ -591,5 +591,13 @@ "table": "Τραπέζι {{name}}", "scanOrder": "Σκανάρετε για μενού και παραγγελία", "scanRead": "Σκανάρετε για το μενού" + }, + "orderingLink": { + "title": "Ο σύνδεσμος παραγγελιών σας", + "intro": "Εδώ οι πελάτες παραγγέλνουν για παραλαβή και διανομή και κλείνουν τραπέζι. Μοιραστείτε τον, βάλτε τον στην ιστοσελίδα σας ή τυπώστε τον QR για φυλλάδια και τη βιτρίνα.", + "copy": "Αντιγραφή", + "copied": "Ο σύνδεσμος αντιγράφηκε", + "open": "Άνοιγμα", + "print": "Εκτύπωση" } } diff --git a/packages/i18n/locales/en/manager.json b/packages/i18n/locales/en/manager.json index 2e93e07..7a05769 100644 --- a/packages/i18n/locales/en/manager.json +++ b/packages/i18n/locales/en/manager.json @@ -591,5 +591,13 @@ "table": "Table {{name}}", "scanOrder": "Scan to see the menu and order", "scanRead": "Scan to see the menu" + }, + "orderingLink": { + "title": "Your ordering link", + "intro": "Customers order takeaway and delivery and book tables here. Share it, put it on your website, or print its QR code for flyers and the window.", + "copy": "Copy link", + "copied": "Link copied", + "open": "Open", + "print": "Print" } } diff --git a/tests/e2e/manager.mjs b/tests/e2e/manager.mjs index c257838..06ab410 100644 --- a/tests/e2e/manager.mjs +++ b/tests/e2e/manager.mjs @@ -517,6 +517,8 @@ try { await page.goto(`${APP}/online/fees`) r.check('fees: the page opens from the nav entry, no rules yet', await page.getByTestId('fees-page').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false) && await page.locator('a[href="/online/fees"]').count() >= 1 && await page.getByTestId('rule').count() === 0) + r.check('ordering link: the venue\'s ordering app address is shown, with its QR code', await page.getByTestId('ordering-link').count() === 1 + && (await page.getByTestId('ordering-link-url').textContent()).endsWith('/order/test-site-1') && await page.getByTestId('ordering-link').locator('svg').count() >= 1) await page.getByTestId('area-add').click() await page.getByTestId('area-name').fill('Centre') await page.getByTestId('area-postcodes').fill('24100, 241 31')