Owner 2026-11-23 (plan 6F.4). services/moves.py: every table transfer, lines moved and orders merged
is an order_moves row with its lines (order_move_items: line, quantity then); OrderItem.split_from_id
links a split part to its line, so a part carries the moves made before the split; combining moves
the removed lines' moves to the kept one. Alembic 0048: the tables, the column, and a backfill from
the audit notes written before (note='backfill'). A split part now also keeps the line's price change,
kitchen state, course, cost and names (it used to restart as pending at the menu price).
GET /api/orders/{id}/moves (the order's path, each line's); GET /api/reports/moves (+ export).
Waiter: a moved order's banner (T2 -> T5), moved lines marked, a line's Move history. Manager: the
order's Moves tab, each moved line's path, Reports -> Moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
202 lines
9.9 KiB
React
202 lines
9.9 KiB
React
// The manager's routes (plan step 6.14b: the shell on v2). Every page sits in the platform
|
|
// bootstrap (modules, keys, venue, language: @xenia/access); signed-in pages in the frame
|
|
// (shell/AppLayout) with the live connection. A fresh install (no manager yet) goes to the setup
|
|
// wizard; the sign-in page sends you there too.
|
|
import { lazy, Suspense } from 'react'
|
|
import { useQuery } from '@tanstack/react-query'
|
|
import { BrowserRouter, Routes, Route, Navigate, Outlet } from 'react-router-dom'
|
|
import { AccessProvider } from '@xenia/access'
|
|
import { VenueIdentity } from './shell/VenueIdentity'
|
|
import { createI18n } from '@xenia/i18n'
|
|
import { Spinner } from '@xenia/ui'
|
|
import useAuthStore from './store/authStore'
|
|
import AppLayout from './shell/AppLayout'
|
|
import LiveProvider from './live/LiveProvider'
|
|
import client from './api/client'
|
|
|
|
// Auth / setup
|
|
import LoginPage from './pages/LoginPage'
|
|
import SetupWizard from './pages/setup/SetupWizard'
|
|
|
|
// Operation
|
|
import OverviewPage from './pages/overview/OverviewPage'
|
|
import TablesPage from './pages/orders/TablesPage'
|
|
import OrderPage from './pages/orders/OrderPage'
|
|
import OnlineOrdersPage from './pages/online/OnlineOrdersPage'
|
|
|
|
// CRM
|
|
import ContactsPage from './pages/finance/ContactsPage'
|
|
import CustomersPage from './pages/customers/CustomersPage'
|
|
|
|
// Financials
|
|
import ExpensesPage from './pages/finance/ExpensesPage'
|
|
import TabsPage from './pages/finance/TabsPage'
|
|
|
|
// Management
|
|
import ProductsPage from './pages/products/ProductsPage'
|
|
import MediaPage from './pages/media/MediaPage'
|
|
import SignagePage from './pages/signage/SignagePage'
|
|
import TablesConfigPage from './pages/Management/TablesConfigPage'
|
|
import StaffPage from './pages/staff/StaffPage'
|
|
import SessionsPage from './pages/staff/SessionsPage'
|
|
import ApprovalsPage from './pages/staff/ApprovalsPage'
|
|
import ManagementSchedulePage from './pages/schedule/SchedulePage'
|
|
import PrepZonesConfigPage from './pages/printing/PrepZonesPage'
|
|
import PricingPage from './pages/pricing/PricingPage'
|
|
import ScenesPage from './pages/scenes/ScenesPage'
|
|
|
|
// Inventory
|
|
import ThrowawaysPage from './pages/inventory/ThrowawaysPage'
|
|
import StockPage from './pages/inventory/StockPage'
|
|
|
|
// Reports
|
|
import TodayPage from './pages/reports/today/TodayReport'
|
|
import StorePage from './pages/reports/store/StorePage'
|
|
import StaffReportPage from './pages/reports/staff/StaffReport'
|
|
import ProductsReportPage from './pages/reports/products/ProductsReport'
|
|
import PrepZonesPage from './pages/reports/prepzones/PrepZonesReport'
|
|
import ExpensesReportPage from './pages/reports/expenses/ExpensesReport'
|
|
import TechnicalPage from './pages/reports/technical/TechnicalReport'
|
|
import MiscPage from './pages/reports/misc/MiscReport'
|
|
import MovesPage from './pages/reports/moves/MovesReport'
|
|
|
|
// Other
|
|
import { AppsPage, IntegrationsPage } from './pages/platform/ModulesPage'
|
|
import LicensePage from './pages/platform/LicensePage'
|
|
import DevicesPage from './pages/platform/DevicesPage'
|
|
import PhonePage from './pages/PhonePage'
|
|
import SettingsPage from './pages/Settings/SettingsPage'
|
|
import NotesPage from './pages/notes/NotesPage'
|
|
|
|
// Texts for the shared parts (approval dialog, "feature off" screens, component labels).
|
|
// The language follows bootstrap (user -> venue).
|
|
const i18n = createI18n()
|
|
|
|
// Visual check pages for the shared packages, dev builds only (left out of production bundles)
|
|
const UiGallery = import.meta.env.DEV ? lazy(() => import('@xenia/ui/gallery')) : null
|
|
const I18nSample = import.meta.env.DEV ? lazy(() => import('@xenia/i18n/sample')) : null
|
|
|
|
function Loading() {
|
|
return <div className="min-h-screen bg-canvas grid place-items-center"><Spinner /></div>
|
|
}
|
|
|
|
/** A token kept from an earlier visit: who it belongs to (else it is dropped and you sign in again). */
|
|
function AuthRehydrator({ children }) {
|
|
const { token, user, rehydrate, logout } = useAuthStore()
|
|
const needed = !!token && !user
|
|
const { isPending } = useQuery({
|
|
queryKey: ['auth-me', token], enabled: needed, retry: false, staleTime: Infinity,
|
|
queryFn: () => client.get('/api/auth/me').then(r => { rehydrate(r.data, token); return r.data }).catch(e => { logout(); throw e }),
|
|
})
|
|
if (needed && isPending) return <Loading />
|
|
return children
|
|
}
|
|
|
|
function RequireAuth({ children }) {
|
|
const token = useAuthStore(s => s.token)
|
|
return token ? children : <Navigate to="/login" replace />
|
|
}
|
|
|
|
/** The sign-in page, unless nobody can sign in yet (a fresh install): then the setup wizard. */
|
|
function SetupGuard({ children }) {
|
|
const { data, isPending } = useQuery({ queryKey: ['setup-status'], retry: false, queryFn: () => client.get('/api/setup/status').then(r => r.data) })
|
|
if (isPending) return <Loading />
|
|
if (data?.needs_setup) return <Navigate to="/setup" replace />
|
|
return children
|
|
}
|
|
|
|
// Platform bootstrap (modules, permission keys, venue, language) for every real page; it
|
|
// reloads when the session token changes (login, logout, unlock). @xenia/access, plan step 2.5.
|
|
function ManagerRoot() {
|
|
const token = useAuthStore(s => s.token)
|
|
return (
|
|
<AccessProvider client={client} token={token} i18n={i18n} loading={<Loading />}>
|
|
<AuthRehydrator>
|
|
<VenueIdentity><Outlet /></VenueIdentity>
|
|
</AuthRehydrator>
|
|
</AccessProvider>
|
|
)
|
|
}
|
|
|
|
export default function App() {
|
|
return (
|
|
<BrowserRouter>
|
|
<Routes>
|
|
{UiGallery && <Route path="/ui-gallery" element={<Suspense fallback={null}><UiGallery /></Suspense>} />}
|
|
{I18nSample && <Route path="/i18n-sample" element={<Suspense fallback={null}><I18nSample /></Suspense>} />}
|
|
<Route element={<ManagerRoot />}>
|
|
<Route path="/setup" element={<SetupWizard />} />
|
|
<Route path="/login" element={<SetupGuard><LoginPage /></SetupGuard>} />
|
|
|
|
<Route path="/" element={<RequireAuth><LiveProvider><AppLayout /></LiveProvider></RequireAuth>}>
|
|
<Route index element={<Navigate to="/dashboard" replace />} />
|
|
|
|
{/* ── Operation ── */}
|
|
<Route path="dashboard" element={<OverviewPage />} />
|
|
<Route path="tables" element={<TablesPage />} />
|
|
<Route path="online-orders" element={<OnlineOrdersPage />} />
|
|
<Route path="online/fees" element={<Navigate to="/online-orders?tab=settings" replace />} />
|
|
<Route path="online/qr" element={<Navigate to="/tables?view=qr" replace />} />
|
|
<Route path="orders/:orderId" element={<OrderPage />} />
|
|
|
|
{/* ── CRM ── */}
|
|
<Route path="crm/contacts" element={<ContactsPage />} />
|
|
<Route path="crm/customers" element={<CustomersPage />} />
|
|
|
|
{/* ── Financials ── */}
|
|
<Route path="financials/expenses" element={<ExpensesPage />} />
|
|
<Route path="financials/tabs" element={<TabsPage />} />
|
|
|
|
{/* ── Management (Headquarters) ── */}
|
|
<Route path="management/products" element={<ProductsPage />} />
|
|
<Route path="management/media" element={<MediaPage />} />
|
|
<Route path="management/signage" element={<SignagePage />} />
|
|
<Route path="management/tables" element={<TablesConfigPage />} />
|
|
<Route path="management/staff" element={<StaffPage />} />
|
|
<Route path="management/sessions" element={<SessionsPage />} />
|
|
<Route path="management/approvals" element={<ApprovalsPage />} />
|
|
<Route path="management/schedule" element={<ManagementSchedulePage />} />
|
|
<Route path="management/prep-zones" element={<PrepZonesConfigPage />} />
|
|
<Route path="management/pricing" element={<PricingPage />} />
|
|
<Route path="management/scenes" element={<ScenesPage />} />
|
|
|
|
{/* ── Inventory ── */}
|
|
<Route path="inventory/throwaways" element={<ThrowawaysPage />} />
|
|
<Route path="inventory/stock" element={<StockPage />} />
|
|
|
|
{/* ── Reports (Overwatch) ── */}
|
|
<Route path="reports/today" element={<TodayPage />} />
|
|
<Route path="reports/store" element={<StorePage />} />
|
|
<Route path="reports/staff" element={<StaffReportPage />} />
|
|
<Route path="reports/products" element={<ProductsReportPage />} />
|
|
<Route path="reports/prep-zones" element={<PrepZonesPage />} />
|
|
<Route path="reports/expenses" element={<ExpensesReportPage />} />
|
|
<Route path="reports/technical" element={<TechnicalPage />} />
|
|
<Route path="reports/misc" element={<MiscPage />} />
|
|
<Route path="reports/moves" element={<MovesPage />} />
|
|
|
|
{/* ── Apps & Settings ── */}
|
|
<Route path="apps" element={<AppsPage />} />
|
|
<Route path="integrations" element={<IntegrationsPage />} />
|
|
<Route path="license" element={<LicensePage />} />
|
|
<Route path="devices" element={<DevicesPage />} />
|
|
<Route path="apps/phone" element={<PhonePage />} />
|
|
<Route path="settings" element={<SettingsPage />} />
|
|
<Route path="notes" element={<NotesPage />} />
|
|
|
|
{/* ── Legacy redirects (old URLs → new locations) ── */}
|
|
<Route path="contacts" element={<Navigate to="/crm/contacts" replace />} />
|
|
<Route path="customers" element={<Navigate to="/crm/customers" replace />} />
|
|
<Route path="expenses" element={<Navigate to="/financials/expenses" replace />} />
|
|
<Route path="tabs" element={<Navigate to="/financials/tabs" replace />} />
|
|
<Route path="waste" element={<Navigate to="/inventory/throwaways" replace />} />
|
|
<Route path="schedule" element={<Navigate to="/management/schedule" replace />} />
|
|
<Route path="management" element={<Navigate to="/management/products" replace />} />
|
|
<Route path="reports" element={<Navigate to="/reports/today" replace />} />
|
|
</Route>
|
|
</Route>
|
|
</Routes>
|
|
</BrowserRouter>
|
|
)
|
|
}
|