diff --git a/local_backend/tests/test_module_texts.py b/local_backend/tests/test_module_texts.py new file mode 100644 index 0000000..aa43c0d --- /dev/null +++ b/local_backend/tests/test_module_texts.py @@ -0,0 +1,26 @@ +"""Every module (and each of its limits) has a name and description for staff in every +UI language (packages/i18n/locales//modules.json, plan step 2.6c). A new module in +a manifest fails here until its texts exist.""" +import json +from pathlib import Path + +import pytest + +from core.modules.registry import registry + +LOCALES = Path(__file__).resolve().parents[2] / "packages" / "i18n" / "locales" + + +@pytest.mark.parametrize("lang", ["en", "el"]) +def test_every_module_has_texts(lang): + texts = json.loads((LOCALES / lang / "modules.json").read_text(encoding="utf-8")) + missing = [] + for m in registry().values(): + t = texts.get(m.key, {}) + if not t.get("name") or not t.get("description"): + missing.append(m.key) + for lim in m.limits: + if not t.get("limits", {}).get(lim.key): + missing.append(f"{m.key}.limits.{lim.key}") + assert missing == [] + assert set(texts) == set(registry()), "texts for modules that don't exist" diff --git a/manager_dashboard/src/App.jsx b/manager_dashboard/src/App.jsx index 809e902..f09d2b7 100644 --- a/manager_dashboard/src/App.jsx +++ b/manager_dashboard/src/App.jsx @@ -51,7 +51,8 @@ import TechnicalPage from './pages/reports/TechnicalPage' import MiscPage from './pages/reports/MiscPage' // Other -import AppsPage from './pages/AppsPage' +import { AppsPage, IntegrationsPage } from './pages/platform/ModulesPage' +import LicensePage from './pages/platform/LicensePage' import PhonePage from './pages/PhonePage' import SettingsPage from './pages/Settings/SettingsPage' import NotesPage from './pages/NotesPage' @@ -178,6 +179,8 @@ export default function App() { {/* ── Apps & Settings ── */} } /> + } /> + } /> } /> } /> } /> diff --git a/manager_dashboard/src/pages/AppsPage.jsx b/manager_dashboard/src/pages/AppsPage.jsx deleted file mode 100644 index e8fc9ae..0000000 --- a/manager_dashboard/src/pages/AppsPage.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useNavigate } from 'react-router-dom' -import { ChefHat, Phone } from 'lucide-react' - -export default function AppsPage() { - const navigate = useNavigate() - - return ( -
-
- - - -
-
- ) -} diff --git a/manager_dashboard/src/pages/platform/LicensePage.jsx b/manager_dashboard/src/pages/platform/LicensePage.jsx new file mode 100644 index 0000000..1b65179 --- /dev/null +++ b/manager_dashboard/src/pages/platform/LicensePage.jsx @@ -0,0 +1,134 @@ +// License page (plan step 2.6c, APPS_PLATFORM §5): what this venue's license includes, +// until when, with which limits, and when the site last reached the license server. +// Sources: bootstrap `license` (mode/reason), GET /api/system/status (expiry, last sync, +// site id), GET /api/platform/modules (per-module entitlement and limits). +// "Check the license now" = POST /api/system/sync-license (needs the internet). +import { useCallback, useEffect, useState } from 'react' +import toast from 'react-hot-toast' +import { errorMessage } from '@xenia/api' +import { useAccess } from '@xenia/access' +import { useFormat, useTranslation } from '@xenia/i18n' +import { Button, EmptyState, Spinner } from '@xenia/ui' +import client from '../../api/client' + +export default function LicensePage() { + const { t } = useTranslation('manager') + const f = useFormat() + const { license, refresh } = useAccess() + const [status, setStatus] = useState(null) + const [modules, setModules] = useState(null) + const [error, setError] = useState(null) + const [syncing, setSyncing] = useState(false) + + const load = useCallback(async () => { + try { + const [s, m] = await Promise.all([client.get('/api/system/status'), client.get('/api/platform/modules')]) + setStatus(s.data) + setModules(m.data.modules) + setError(null) + } catch (err) { + setError(errorMessage(err, t)) + } + }, [t]) + + useEffect(() => { load() }, [load]) + + async function syncNow() { + setSyncing(true) + try { + const { data } = await client.post('/api/system/sync-license') + await Promise.all([load(), refresh()]) + if (data?.sync_failed) toast.error(t('licensePage.syncFailed')) + else toast.success(t('licensePage.synced')) + } catch (err) { + toast.error(errorMessage(err, t)) + } finally { + setSyncing(false) + } + } + + if (error) return
{t('common:actions.retry')}} />
+ if (!status || !modules) return
+ + const mode = license?.mode + const statusText = mode === 'dev' ? t('licensePage.statusDev') + : mode === 'licensed' ? t('licensePage.statusLicensed') + : t('licensePage.statusFree') + const statusTone = mode === 'licensed' ? 'bg-success-soft text-success-ink' : mode === 'dev' ? 'bg-info-soft text-info-ink' : 'bg-warning-soft text-warning-ink' + const reason = mode === 'free' && license?.reason ? t(`license.${license.reason}`, { defaultValue: '' }) : '' + + const entitlement = m => { + if (!m.entitled) return t('licensePage.notIncluded') + const src = m.entitlement?.source + if (src === 'core') return t('licensePage.included') + if (src === 'dev') return t('licensePage.dev') + if (src === 'free') return t('licensePage.free') + return m.entitlement?.exp ? t('licensePage.inLicenseUntil', { date: f.formatDate(m.entitlement.exp) }) : t('licensePage.inLicense') + } + const sorted = [...modules].sort((a, b) => t(`modules:${a.key}.name`).localeCompare(t(`modules:${b.key}.name`))) + + return ( +
+
+
+
+
{t('licensePage.status')}
+ {statusText} +
+ +
+ {reason &&

{reason}

} +
+
+
{t('licensePage.siteId')}
+
{status.site_id || '—'}
+
+
+
{t('licensePage.expires')}
+
+ {status.expires_at ? f.formatDate(status.expires_at, 'dateMedium') : '—'} + {status.days_until_expiry != null && status.days_until_expiry >= 0 && ( + · {t('licensePage.daysLeft', { count: status.days_until_expiry })} + )} +
+
+
+
{t('licensePage.lastSync')}
+
{status.last_sync ? f.formatRelative(status.last_sync) : t('licensePage.never')}
+
+
+ {status.sync_failed && status.offline_days > 0 && ( +

{t('licensePage.offline', { count: status.offline_days })}

+ )} +
+ +
+

{t('licensePage.modules')}

+ + + + + + + + + + {sorted.map(m => ( + + + + + + ))} + +
{t('licensePage.module')}{t('licensePage.status')}{t('licensePage.limits')}
{t(`modules:${m.key}.name`)}{entitlement(m)} + {m.limits.map(l => ( +
+ {t(`modules:${m.key}.limits.${l.key}`)}: {l.value == null ? t('modules.unlimited') : l.value} +
+ ))} +
+
+
+ ) +} diff --git a/manager_dashboard/src/pages/platform/ModulesPage.jsx b/manager_dashboard/src/pages/platform/ModulesPage.jsx new file mode 100644 index 0000000..349c9e9 --- /dev/null +++ b/manager_dashboard/src/pages/platform/ModulesPage.jsx @@ -0,0 +1,169 @@ +// Apps and Integrations pages (plan step 2.6c, APPS_PLATFORM §4, D-3, D-19): the module +// catalogue from GET /api/platform/modules as cards. A manager with core.modules.manage +// turns modules on/off (PUT /api/platform/modules/{key}); everyone else sees the state. +// Turning one off warns first which modules depending on it stop too. After a change the +// platform bootstrap is reloaded, so the sidebar and every guard follow at once. +import { useCallback, useEffect, useMemo, useState } from 'react' +import { useNavigate } from 'react-router-dom' +import toast from 'react-hot-toast' +import { errorMessage } from '@xenia/api' +import { useAccess, useCan } from '@xenia/access' +import { useTranslation } from '@xenia/i18n' +import { Button, Dialog, EmptyState, Spinner, Switch } from '@xenia/ui' +import client from '../../api/client' +import { moduleState, stoppedBy } from './modulesLogic' + +// Modules with a page in the manager: the card gets an "Open" button +const OPEN_PATH = { kds: '/kds', caller_id: '/apps/phone' } + +export function AppsPage() { + const { t } = useTranslation('manager') + return +} + +export function IntegrationsPage() { + const { t } = useTranslation('manager') + return +} + +function ModulesPage({ kinds, intro }) { + const { t } = useTranslation('manager') + const { refresh } = useAccess() + const canManage = useCan('core.modules.manage') + const [modules, setModules] = useState(null) + const [error, setError] = useState(null) + const [confirm, setConfirm] = useState(null) // { module, stopped } + const [busy, setBusy] = useState(null) // key being saved + + const load = useCallback(async () => { + try { + const { data } = await client.get('/api/platform/modules') + setModules(data.modules) + setError(null) + } catch (err) { + setError(errorMessage(err, t)) + } + }, [t]) + + useEffect(() => { load() }, [load]) + + async function save(m, enabled) { + setBusy(m.key) + try { + await client.put(`/api/platform/modules/${m.key}`, { enabled }) + await Promise.all([load(), refresh()]) + toast.success(t('modules.changed', { name: t(`modules:${m.key}.name`), state: enabled ? t('modules.on') : t('modules.off') })) + } catch (err) { + toast.error(errorMessage(err, t)) + } finally { + setBusy(null) + } + } + + function toggle(m, enabled) { + const stopped = enabled ? [] : stoppedBy(m.key, modules) + if (stopped.length) setConfirm({ module: m, stopped }) + else save(m, enabled) + } + + const sections = useMemo(() => { + if (!modules) return [] + const byName = (a, b) => t(`modules:${a.key}.name`).localeCompare(t(`modules:${b.key}.name`)) + return kinds + .map(kind => ({ kind, items: modules.filter(m => m.kind === kind).sort(byName) })) + .filter(s => s.items.length) + }, [modules, kinds, t]) + + if (error) return
{t('common:actions.retry')}} />
+ if (!modules) return
+ + return ( +
+
+

{intro}

+ {!canManage &&

{t('modules.readOnly')}

} +
+ {sections.map(({ kind, items }) => ( +
+ {kinds.length > 1 &&

{t(`modules.sections.${kind}`)}

} +
+ {items.map(m => ( + + ))} +
+
+ ))} + + setConfirm(null)} + size="sm" + title={confirm ? t('modules.confirmOffTitle', { name: t(`modules:${confirm.module.key}.name`) }) : ''} + footer={confirm && ( + <> + + + + )} + > + {confirm && ( + + {t('modules.confirmOffBody', { list: confirm.stopped.map(s => t(`modules:${s.key}.name`)).join(', ') })} + + )} + +
+ ) +} + +function ModuleCard({ m, modules, canManage, busy, onToggle }) { + const { t } = useTranslation('manager') + const navigate = useNavigate() + const name = t(`modules:${m.key}.name`) + const state = moduleState(m) + const label = key => t(`modules:${key}.name`) + const waitingFor = m.depends.filter(d => !modules.find(x => x.key === d)?.effective) + const chip = { + always: ['bg-surface-2 text-ink-2', t('modules.alwaysOn')], + not_licensed: ['bg-warning-soft text-warning-ink', t('modules.notLicensed')], + on: ['bg-success-soft text-success-ink', t('modules.on')], + waiting: ['bg-warning-soft text-warning-ink', t('modules.waiting', { list: waitingFor.map(label).join(', ') })], + off: ['bg-surface-2 text-ink-3', t('modules.off')], + }[state] + + return ( +
+
+
+
{name}
+ {chip[1]} +
+ {m.can_disable && state !== 'not_licensed' && ( + onToggle(m, on)} + aria-label={t('modules.toggleLabel', { name })} + /> + )} +
+

{t(`modules:${m.key}.description`)}

+ {m.depends.length > 0 && state !== 'waiting' && ( +

{t('modules.needs', { list: m.depends.map(label).join(', ') })}

+ )} + {m.limits.length > 0 && ( +
+ {m.limits.map(l => ( +
+
{t(`modules:${m.key}.limits.${l.key}`)}
+
{l.value == null ? t('modules.unlimited') : l.value}
+
+ ))} +
+ )} + {OPEN_PATH[m.key] && state === 'on' && ( +
+ )} +
+ ) +} diff --git a/manager_dashboard/src/pages/platform/modulesLogic.js b/manager_dashboard/src/pages/platform/modulesLogic.js new file mode 100644 index 0000000..da6dd95 --- /dev/null +++ b/manager_dashboard/src/pages/platform/modulesLogic.js @@ -0,0 +1,28 @@ +// Pure helpers for the Apps/Integrations pages (plan step 2.6c). + +/** Modules that stop working if `key` is off (they depend on it, directly or not), currently on. */ +export function stoppedBy(key, modules) { + const out = [] + const seen = new Set([key]) + let frontier = [key] + while (frontier.length) { + const next = [] + for (const m of modules) { + if (seen.has(m.key) || !m.depends.some(d => frontier.includes(d))) continue + seen.add(m.key) + next.push(m.key) + if (m.effective) out.push(m) + } + frontier = next + } + return out +} + +/** The card's state: always | not_licensed | on | waiting | off */ +export function moduleState(m) { + if (!m.can_disable) return 'always' + if (!m.entitled) return 'not_licensed' + if (m.enabled && m.effective) return 'on' + if (m.enabled) return 'waiting' + return 'off' +} diff --git a/manager_dashboard/src/shell/nav.js b/manager_dashboard/src/shell/nav.js index e78232f..2764506 100644 --- a/manager_dashboard/src/shell/nav.js +++ b/manager_dashboard/src/shell/nav.js @@ -16,7 +16,7 @@ import { BookUser, Users, Receipt, CreditCard, Package, TableProperties, UserCog, CalendarDays, Trash2, Boxes, BarChart2, TrendingUp, Users2, ShoppingCart, Tag, Activity, Printer, ConciergeBell, FileText, - AppWindow, Settings, CookingPot, StickyNote, Percent, + AppWindow, Settings, CookingPot, StickyNote, Percent, Plug, BadgeCheck, } from 'lucide-react' const DASH = 'core.dashboard.access' @@ -95,12 +95,14 @@ export const NAV = [ export const NAV_BOTTOM = [ { to: '/apps', icon: AppWindow, label: 'nav.apps', module: 'core', perm: DASH }, + { to: '/integrations', icon: Plug, label: 'nav.integrations', module: 'core', perm: DASH }, + { to: '/license', icon: BadgeCheck, label: 'nav.license', module: 'core', perm: DASH }, { to: '/settings', icon: Settings, label: 'nav.settings', module: 'core', perm: 'core.settings.manage' }, ] // Pages that aren't in the sidebar but still have a title and a guard const EXTRA = [ - { to: '/apps/phone', label: 'nav.phone', parent: 'nav.apps', module: 'caller_id', perm: DASH }, + { to: '/apps/phone', label: 'nav.phone', parent: 'nav.integrations', module: 'caller_id', perm: DASH }, { to: '/kds', label: 'nav.kds', module: 'kds', perm: DASH }, { prefix: '/orders/', label: 'nav.order', module: 'ordering', perm: DASH }, ] diff --git a/packages/i18n/locales/el/manager.json b/packages/i18n/locales/el/manager.json index 21c1461..a6636f6 100644 --- a/packages/i18n/locales/el/manager.json +++ b/packages/i18n/locales/el/manager.json @@ -40,7 +40,9 @@ "settings": "Ρυθμίσεις", "order": "Παραγγελία", "kds": "Οθόνη κουζίνας", - "soon": "σύντομα" + "soon": "σύντομα", + "integrations": "Συνδέσεις", + "license": "Άδεια" }, "profile": { "edit": "Επεξεργασία προφίλ", @@ -77,5 +79,53 @@ "lock": { "title": "Κλειδωμένο", "signOutInstead": "Αποσύνδεση" + }, + "modules": { + "appsIntro": "Ενεργοποιήστε ή απενεργοποιήστε μέρη του συστήματος για αυτό το κατάστημα. Ό,τι είναι κλειστό εξαφανίζεται από όλες τις οθόνες και τα δεδομένα του μένουν ασφαλή.", + "integrationsIntro": "Συνδέσεις με άλλο εξοπλισμό και υπηρεσίες.", + "sections": { + "app": "Εφαρμογές συσκευών", + "feature": "Λειτουργίες", + "core": "Περιλαμβάνονται πάντα" + }, + "on": "Ενεργό", + "off": "Ανενεργό", + "alwaysOn": "Πάντα ενεργό", + "notLicensed": "Δεν περιλαμβάνεται στην άδεια", + "waiting": "Περιμένει: {{list}}", + "needs": "Χρειάζεται: {{list}}", + "open": "Άνοιγμα", + "unlimited": "Απεριόριστο", + "toggleLabel": "{{name}} ενεργό ή ανενεργό", + "confirmOffTitle": "Απενεργοποίηση: {{name}};", + "confirmOffBody": "Όσο είναι κλειστό, σταματούν να λειτουργούν και: {{list}}.", + "turnOff": "Απενεργοποίηση", + "changed": "{{name}}: {{state}}", + "readOnly": "Μόνο όποιος έχει δικαίωμα διαχείρισης εφαρμογών μπορεί να τα αλλάξει." + }, + "licensePage": { + "status": "Κατάσταση", + "statusDev": "Λειτουργία ανάπτυξης (όλες οι λειτουργίες, χωρίς όρια)", + "statusLicensed": "Με άδεια", + "statusFree": "Δωρεάν έκδοση", + "siteId": "Κωδικός καταστήματος", + "expires": "Ισχύει μέχρι", + "daysLeft_one": "Απομένει {{count}} ημέρα", + "daysLeft_other": "Απομένουν {{count}} ημέρες", + "lastSync": "Τελευταία επικοινωνία με τον server αδειών", + "never": "ποτέ", + "syncNow": "Έλεγχος άδειας τώρα", + "synced": "Η άδεια ελέγχθηκε", + "syncFailed": "Δεν υπάρχει σύνδεση με τον server αδειών", + "offline": "Καμία επικοινωνία με τον server αδειών εδώ και {{count}} ημέρες. Το κατάστημα συνεχίζει να λειτουργεί μέχρι να λήξει η άδεια.", + "modules": "Λειτουργίες", + "module": "Λειτουργία", + "included": "Περιλαμβάνεται", + "inLicense": "Στην άδειά σας", + "inLicenseUntil": "Στην άδειά σας μέχρι {{date}}", + "free": "Δωρεάν έκδοση", + "dev": "Ανάπτυξη", + "notIncluded": "Δεν περιλαμβάνεται", + "limits": "Όρια" } } diff --git a/packages/i18n/locales/el/modules.json b/packages/i18n/locales/el/modules.json new file mode 100644 index 0000000..cbe63cd --- /dev/null +++ b/packages/i18n/locales/el/modules.json @@ -0,0 +1,123 @@ +{ + "caller_id": { + "name": "Αναγνώριση κλήσης", + "description": "Εισερχόμενες κλήσεις από το τηλεφωνικό κέντρο του καταστήματος (Grandstream UCM)." + }, + "catalog": { + "name": "Κατάλογος", + "description": "Προϊόντα, κατηγορίες, επιλογές, τραπέζια και ζώνες ετοιμασίας." + }, + "chat": { + "name": "Συνομιλία προσωπικού", + "description": "Συνομιλία του προσωπικού και μηνύματα του υπευθύνου προς το προσωπικό." + }, + "connect_menu": { + "name": "QR μενού", + "description": "Το online μενού με QR, συγχρονισμένο με τον κατάλογο." + }, + "connect_orders": { + "name": "Online παραγγελίες", + "description": "Παραγγελίες από το QR μενού, που έρχονται από το cloud." + }, + "connect_remote": { + "name": "Απομακρυσμένη διαχείριση", + "description": "Ζωντανά στοιχεία για την εφαρμογή απομακρυσμένης διαχείρισης του ιδιοκτήτη." + }, + "core": { + "name": "Βασικό σύστημα", + "description": "Σύνδεση, προσωπικό, ρυθμίσεις, άδεια, σύστημα και ζωντανές ενημερώσεις. Πάντα ενεργό." + }, + "crm": { + "name": "Πελάτες", + "description": "Αρχείο πελατών." + }, + "customer_display": { + "name": "Οθόνη πελάτη", + "description": "Οθόνη προς τον πελάτη δίπλα σε ταμείο πάγκου (έρχεται σύντομα).", + "limits": { + "devices": "Οθόνες πελάτη" + } + }, + "expenses": { + "name": "Έξοδα", + "description": "Έξοδα, πληρωμές και βιβλίο προμηθευτών." + }, + "fiscal": { + "name": "Φορολογικός μηχανισμός", + "description": "Αποστολή αποδείξεων στον φορολογικό μηχανισμό (ΦΗΜ) μέσω του φακέλου γέφυρας." + }, + "history": { + "name": "Ιστορικό παραγγελιών", + "description": "Παλιές παραγγελίες και σύνοψη εργάσιμων ημερών (μόνο προβολή). Δωρεάν, με σύντομο ιστορικό.", + "limits": { + "history_days": "Ημέρες ιστορικού για προβολή" + } + }, + "inventory": { + "name": "Αποθήκη", + "description": "Καταγραφή απορριμμάτων και κόστος προϊόντων." + }, + "kds": { + "name": "Οθόνη κουζίνας", + "description": "Οθόνες στην κουζίνα ή στο μπαρ με τις παραγγελίες προς ετοιμασία.", + "limits": { + "devices": "Οθόνες κουζίνας" + } + }, + "menu_tablet": { + "name": "Tablet μενού", + "description": "Κατάλογος αυτοεξυπηρέτησης σε tablet (έρχεται σύντομα).", + "limits": { + "devices": "Tablet μενού" + } + }, + "notes": { + "name": "Σημειώσεις", + "description": "Σημειώσεις και εργασίες του καταστήματος." + }, + "ordering": { + "name": "Παραγγελίες", + "description": "Παραγγελίες, πληρωμές, εργάσιμη ημέρα, βάρδιες, ταμείο και εκτύπωση κουζίνας." + }, + "pos_counter": { + "name": "Ταμείο πάγκου", + "description": "Τερματικό στον πάγκο για γρήγορες παραγγελίες (έρχεται σύντομα).", + "limits": { + "devices": "Τερματικά πάγκου" + } + }, + "pricing": { + "name": "Τιμολόγηση", + "description": "Ομάδες τιμών, happy hour, τροποποιητές, προσφορές και εκπτώσεις σερβιτόρων." + }, + "reports": { + "name": "Αναφορές", + "description": "Πλήρεις αναφορές πωλήσεων, προϊόντων, προσωπικού και εκτυπωτών, εξαγωγή CSV και εκτυπωμένες αναφορές.", + "limits": { + "history_days": "Ημέρες που καλύπτουν οι αναφορές" + } + }, + "reservations": { + "name": "Κρατήσεις", + "description": "Κρατήσεις τραπεζιών." + }, + "signage": { + "name": "Ψηφιακή σήμανση", + "description": "Μενού και προσφορές σε τηλεοράσεις (έρχεται σύντομα).", + "limits": { + "devices": "Οθόνες σήμανσης" + } + }, + "staff_planning": { + "name": "Προγραμματισμός προσωπικού", + "description": "Πρόγραμμα βαρδιών και μισθοδοσία." + }, + "tabs": { + "name": "Καρτέλες", + "description": "Καρτέλες πληρωμής αργότερα για τακτικούς πελάτες." + }, + "waiter_app": { + "name": "Εφαρμογή σερβιτόρων", + "description": "Λήψη παραγγελιών από τα κινητά των σερβιτόρων (web και εφαρμογή Android)." + } +} diff --git a/packages/i18n/locales/en/manager.json b/packages/i18n/locales/en/manager.json index 0b4e983..c193d5d 100644 --- a/packages/i18n/locales/en/manager.json +++ b/packages/i18n/locales/en/manager.json @@ -40,7 +40,9 @@ "settings": "Settings", "order": "Order", "kds": "Kitchen display", - "soon": "soon" + "soon": "soon", + "integrations": "Integrations", + "license": "License" }, "profile": { "edit": "Edit profile", @@ -77,5 +79,53 @@ "lock": { "title": "Locked", "signOutInstead": "Sign out instead" + }, + "modules": { + "appsIntro": "Turn parts of the system on or off for this venue. What's off disappears from every screen and its data stays safe.", + "integrationsIntro": "Connections to other equipment and services.", + "sections": { + "app": "Device apps", + "feature": "Features", + "core": "Always included" + }, + "on": "On", + "off": "Off", + "alwaysOn": "Always on", + "notLicensed": "Not in your license", + "waiting": "Waiting for {{list}}", + "needs": "Needs {{list}}", + "open": "Open", + "unlimited": "Unlimited", + "toggleLabel": "{{name}} on or off", + "confirmOffTitle": "Turn off {{name}}?", + "confirmOffBody": "These stop working too while it's off: {{list}}.", + "turnOff": "Turn off", + "changed": "{{name}} is now {{state}}", + "readOnly": "Only someone with permission to manage apps can change these." + }, + "licensePage": { + "status": "Status", + "statusDev": "Development mode (every module, no limits)", + "statusLicensed": "Licensed", + "statusFree": "Free version", + "siteId": "Site ID", + "expires": "Valid until", + "daysLeft_one": "{{count}} day left", + "daysLeft_other": "{{count}} days left", + "lastSync": "Last contact with the license server", + "never": "never", + "syncNow": "Check the license now", + "synced": "License checked", + "syncFailed": "Couldn't reach the license server", + "offline": "No contact with the license server for {{count}} days. The venue keeps working until the license expires.", + "modules": "Modules", + "module": "Module", + "included": "Included", + "inLicense": "In your license", + "inLicenseUntil": "In your license until {{date}}", + "free": "Free version", + "dev": "Development", + "notIncluded": "Not included", + "limits": "Limits" } } diff --git a/packages/i18n/locales/en/modules.json b/packages/i18n/locales/en/modules.json new file mode 100644 index 0000000..c28a0f5 --- /dev/null +++ b/packages/i18n/locales/en/modules.json @@ -0,0 +1,123 @@ +{ + "caller_id": { + "name": "Caller ID", + "description": "Incoming phone calls from the venue's phone system (Grandstream UCM)." + }, + "catalog": { + "name": "Catalogue", + "description": "Products, categories, options, tables and prep zones." + }, + "chat": { + "name": "Staff chat", + "description": "Staff chat and manager messages to staff." + }, + "connect_menu": { + "name": "QR menu", + "description": "The online QR menu, kept in sync with the catalogue." + }, + "connect_orders": { + "name": "Online orders", + "description": "Orders placed from the QR menu, brought in from the cloud." + }, + "connect_remote": { + "name": "Remote manager", + "description": "Live figures for the owner's remote manager app." + }, + "core": { + "name": "Core", + "description": "Sign-in, staff, settings, license, system and live updates. Always on." + }, + "crm": { + "name": "Customers", + "description": "Customer records." + }, + "customer_display": { + "name": "Customer display", + "description": "A screen facing the customer at a counter POS (coming soon).", + "limits": { + "devices": "Customer displays" + } + }, + "expenses": { + "name": "Expenses", + "description": "Expenses, payments and the supplier book." + }, + "fiscal": { + "name": "Fiscal device", + "description": "Sends receipts to the fiscal device (ΦΗΜ) through its folder bridge." + }, + "history": { + "name": "Order history", + "description": "Past orders and business-day summaries (read only). Free, with a short history.", + "limits": { + "history_days": "Days of history you can view" + } + }, + "inventory": { + "name": "Inventory", + "description": "Waste log and product costs." + }, + "kds": { + "name": "Kitchen display", + "description": "Screens in the kitchen or bar showing the orders to prepare.", + "limits": { + "devices": "Kitchen screens" + } + }, + "menu_tablet": { + "name": "Menu tablet", + "description": "A self-service catalogue on a tablet (coming soon).", + "limits": { + "devices": "Menu tablets" + } + }, + "notes": { + "name": "Notes", + "description": "Venue notes and to-dos." + }, + "ordering": { + "name": "Ordering", + "description": "Orders, payments, business day, shifts, cash and kitchen printing." + }, + "pos_counter": { + "name": "Counter POS", + "description": "A counter terminal for quick orders (coming soon).", + "limits": { + "devices": "Counter terminals" + } + }, + "pricing": { + "name": "Pricing", + "description": "Price groups, happy hours, modifiers, deals and waiter discounts." + }, + "reports": { + "name": "Reports", + "description": "Full sales, product, staff and printer reports, CSV export and printed reports.", + "limits": { + "history_days": "Days of history reports can cover" + } + }, + "reservations": { + "name": "Reservations", + "description": "Table reservations." + }, + "signage": { + "name": "Digital signage", + "description": "Menus and promotions on TVs (coming soon).", + "limits": { + "devices": "Signage screens" + } + }, + "staff_planning": { + "name": "Staff planning", + "description": "Shift schedule and payroll." + }, + "tabs": { + "name": "Tabs", + "description": "Pay-later tabs for regular customers." + }, + "waiter_app": { + "name": "Waiter app", + "description": "Order taking on the waiters' phones (web and Android app)." + } +} diff --git a/packages/i18n/src/resources.js b/packages/i18n/src/resources.js index 639f8d0..7d1d2a8 100644 --- a/packages/i18n/src/resources.js +++ b/packages/i18n/src/resources.js @@ -1,20 +1,23 @@ // Every locale file, bundled (they're small; no loading step, no flash of keys). // Layout (APPS_PLATFORM §8): locales//.json. English is the source. // Namespaces: common (shared words, component labels), errors (backend error codes, -// local_backend/core/errors.py; tests/errors.test.mjs keeps them complete), manager (the manager shell, 2.6), +// local_backend/core/errors.py; tests/errors.test.mjs keeps them complete), manager (the manager shell, 2.6), modules (module +// names/descriptions/limits for staff; local_backend/tests/test_module_texts.py keeps them complete), // dev (sample screens). Apps add theirs here as they're converted: waiter, terminal, modules. import elCommon from '../locales/el/common.json' import elDev from '../locales/el/dev.json' import elErrors from '../locales/el/errors.json' import elManager from '../locales/el/manager.json' +import elModules from '../locales/el/modules.json' import enCommon from '../locales/en/common.json' import enDev from '../locales/en/dev.json' import enErrors from '../locales/en/errors.json' import enManager from '../locales/en/manager.json' +import enModules from '../locales/en/modules.json' -export const NAMESPACES = ['common', 'errors', 'manager', 'dev'] +export const NAMESPACES = ['common', 'errors', 'manager', 'modules', 'dev'] export const resources = { - en: { common: enCommon, errors: enErrors, manager: enManager, dev: enDev }, - el: { common: elCommon, errors: elErrors, manager: elManager, dev: elDev }, + en: { common: enCommon, errors: enErrors, manager: enManager, modules: enModules, dev: enDev }, + el: { common: elCommon, errors: elErrors, manager: elManager, modules: elModules, dev: elDev }, } diff --git a/tests/e2e/manager.mjs b/tests/e2e/manager.mjs index 45bf8b2..c185692 100644 --- a/tests/e2e/manager.mjs +++ b/tests/e2e/manager.mjs @@ -108,6 +108,43 @@ try { await page.waitForFunction(() => document.querySelector('[data-testid="sidebar"]')?.innerText.includes('Management'), null, { timeout: 5000 }).catch(() => {}) r.check('language → English again', await sidebar.getByText('Management').count() > 0) + // ── 2.6c: Apps page: module cards, toggles, dependency warning ───────────── + await page.goto(`${APP}/apps`) + await page.getByTestId('module-notes').waitFor({ timeout: 15_000 }) + const card = key => page.getByTestId(`module-${key}`) + r.check('apps: cards for device apps, features and core', await card('kds').count() === 1 && await card('notes').count() === 1 && await card('core').count() === 1) + r.check('apps: core is "Always on" with no switch', await card('core').getAttribute('data-state') === 'always' && await card('core').getByRole('switch').count() === 0) + await card('notes').getByRole('switch').click() + await page.waitForFunction(() => document.querySelector('[data-testid="module-notes"]')?.dataset.state === 'off', null, { timeout: 8000 }).catch(() => {}) + await sidebar.getByText('Management').click().catch(() => {}) + r.check('apps: notes switched off from its card → state off, gone from the sidebar', + await card('notes').getAttribute('data-state') === 'off' && await sidebar.getByText('Notes', { exact: true }).count() === 0) + await card('notes').getByRole('switch').click() + await page.waitForFunction(() => document.querySelector('[data-testid="module-notes"]')?.dataset.state === 'on', null, { timeout: 8000 }).catch(() => {}) + r.check('apps: notes back on', await card('notes').getAttribute('data-state') === 'on' && await sidebar.getByText('Notes', { exact: true }).count() === 1) + await card('ordering').getByRole('switch').click() + const stopped = await page.getByTestId('confirm-stopped').textContent({ timeout: 5000 }).catch(() => '') + r.check('apps: turning off Ordering first lists what stops with it', ['Kitchen display', 'Waiter app', 'Pricing'].every(n => stopped.includes(n)), stopped) + await page.getByRole('dialog').getByRole('button', { name: 'Cancel' }).click() + r.check('apps: Cancel leaves Ordering on', await card('ordering').getAttribute('data-state') === 'on') + r.check('apps: a card with a page has "Open" (KDS)', await card('kds').getByRole('button', { name: 'Open' }).count() === 1) + + // ── 2.6c: Integrations and License ───────────────────────────────────────── + await page.goto(`${APP}/integrations`) + await card('fiscal').waitFor({ timeout: 15_000 }) + r.check('integrations: only integrations (fiscal, caller ID)', await card('caller_id').count() === 1 && await card('kds').count() === 0) + await page.goto(`${APP}/license`) + await page.getByTestId('license-status').waitFor({ timeout: 20_000 }) + r.check('license: development mode, site id, a row per module', + (await page.getByTestId('license-mode').textContent()).startsWith('Development mode') + && (await page.getByTestId('license-site').textContent()) === 'test-site-1' + && await page.locator('[data-testid^="license-row-"]').count() >= 20) + r.check('license: limits are shown (kitchen screens: unlimited in dev)', (await page.getByTestId('license-row-kds').textContent()).includes('Kitchen screens')) + await page.screenshot({ path: path.join(OUT, 'manager-license.png'), fullPage: true }) + await page.goto(`${APP}/apps`) + await card('notes').waitFor() + await page.screenshot({ path: path.join(OUT, 'manager-apps.png'), fullPage: true }) + // ── Lock screen: a wrong PIN stays locked (no logout), the right one unlocks ─ await page.goto(`${APP}/dashboard`) await sleep(1500)