From 8a02173450737d3d4c659147fd99bf9aca8b9a24 Mon Sep 17 00:00:00 2001 From: bonamin Date: Wed, 18 Nov 2026 09:01:51 +0200 Subject: [PATCH] feat(manager): the overview, online orders and the day summary on v2 (platform-v2 step 6.2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DashboardPage (2.8k lines) → src/pages/overview/: OverviewPage + cards (shifts, tables, pending prints, notes, bookings, messages) and dialogs (order at a glance, shift review / end with the cash handover, day summary with cash count and checks); arithmetic in overviewLogic.js (tests/overview.test.mjs). Data via useLiveQuery: orders and tables live, day and shifts every 15 s. Bookings typed in venue time; decline reason in a dialog. - OnlineOrdersPage → src/pages/online/ on react-query + live events; unused API helpers dropped. - WorkdaySummaryModal → overview/DaySummaryDialog + DaySummaryTabs. - Every text in manager.json (en + el, 342 keys); tokens only; v2.json adds overview, hooks. - Backend: business day open/close answer only with codes (license.locked, license.expired, business_day.orders_open); XeniaError's v1 `detail` removed. - @xenia/i18n: formatDateTime with Intl options threw "unknown date style" (fixed, tested). - e2e manager.mjs: open the day, a shift (start, stats, end short), a live table, a booking, day stats, Greek, close the day (forced), online orders. Co-Authored-By: Claude Opus 5.5 --- local_backend/core/errors.py | 5 +- local_backend/routers/business_day.py | 18 +- local_backend/tests/test_errors.py | 14 - manager_dashboard/src/App.jsx | 6 +- manager_dashboard/src/api/client.js | 13 +- .../src/components/WorkdaySummaryModal.jsx | 907 ------ manager_dashboard/src/pages/DashboardPage.jsx | 2768 ----------------- .../src/pages/OnlineOrdersPage.jsx | 395 --- .../src/pages/online/OnlineOrdersPage.jsx | 160 + .../src/pages/online/onlineOrdersLogic.js | 22 + .../src/pages/overview/BookingsCard.jsx | 190 ++ .../src/pages/overview/DaySummaryDialog.jsx | 91 + .../src/pages/overview/DaySummaryTabs.jsx | 289 ++ .../src/pages/overview/MessagesCard.jsx | 111 + .../src/pages/overview/NotesCard.jsx | 54 + .../src/pages/overview/OrderDialog.jsx | 170 + .../src/pages/overview/OverviewPage.jsx | 215 ++ .../src/pages/overview/PendingPrints.jsx | 74 + .../src/pages/overview/ShiftDialog.jsx | 206 ++ .../src/pages/overview/ShiftsCard.jsx | 87 + .../src/pages/overview/TablesCard.jsx | 48 + manager_dashboard/src/pages/overview/hooks.js | 20 + .../src/pages/overview/overviewLogic.js | 256 ++ .../src/pages/overview/parts.jsx | 99 + manager_dashboard/src/pages/overview/tones.js | 16 + manager_dashboard/tests/overview.test.mjs | 137 + manager_dashboard/v2.json | 9 +- packages/i18n/locales/el/manager.json | 402 ++- packages/i18n/locales/en/manager.json | 402 ++- packages/i18n/src/format.js | 5 +- packages/i18n/tests/format.test.mjs | 6 + tests/e2e/manager.mjs | 92 + 32 files changed, 3161 insertions(+), 4126 deletions(-) delete mode 100644 manager_dashboard/src/components/WorkdaySummaryModal.jsx delete mode 100644 manager_dashboard/src/pages/DashboardPage.jsx delete mode 100644 manager_dashboard/src/pages/OnlineOrdersPage.jsx create mode 100644 manager_dashboard/src/pages/online/OnlineOrdersPage.jsx create mode 100644 manager_dashboard/src/pages/online/onlineOrdersLogic.js create mode 100644 manager_dashboard/src/pages/overview/BookingsCard.jsx create mode 100644 manager_dashboard/src/pages/overview/DaySummaryDialog.jsx create mode 100644 manager_dashboard/src/pages/overview/DaySummaryTabs.jsx create mode 100644 manager_dashboard/src/pages/overview/MessagesCard.jsx create mode 100644 manager_dashboard/src/pages/overview/NotesCard.jsx create mode 100644 manager_dashboard/src/pages/overview/OrderDialog.jsx create mode 100644 manager_dashboard/src/pages/overview/OverviewPage.jsx create mode 100644 manager_dashboard/src/pages/overview/PendingPrints.jsx create mode 100644 manager_dashboard/src/pages/overview/ShiftDialog.jsx create mode 100644 manager_dashboard/src/pages/overview/ShiftsCard.jsx create mode 100644 manager_dashboard/src/pages/overview/TablesCard.jsx create mode 100644 manager_dashboard/src/pages/overview/hooks.js create mode 100644 manager_dashboard/src/pages/overview/overviewLogic.js create mode 100644 manager_dashboard/src/pages/overview/parts.jsx create mode 100644 manager_dashboard/src/pages/overview/tones.js create mode 100644 manager_dashboard/tests/overview.test.mjs diff --git a/local_backend/core/errors.py b/local_backend/core/errors.py index 8d64b9d..5657ad2 100644 --- a/local_backend/core/errors.py +++ b/local_backend/core/errors.py @@ -263,13 +263,12 @@ CODES: dict[str, tuple[int, str]] = { class XeniaError(Exception): """An API error with a registered code. raise XeniaError("order.not_found", order_id=5).""" - def __init__(self, code: str, status: int | None = None, *, detail=None, **params): + def __init__(self, code: str, status: int | None = None, **params): if code not in CODES: raise KeyError(f"unregistered error code {code!r}: add it to core/errors.py CODES") default_status, template = CODES[code] self.code = code self.status = status or default_status - self.detail = detail # v1-shaped `detail` some old pages still read (6.x removes) self.params = params try: self.message = template.format(**params) @@ -284,7 +283,7 @@ def error_body(code: str, message: str, params: dict | None = None, detail=None) async def _xenia_error_handler(request: Request, exc: XeniaError): - return JSONResponse(error_body(exc.code, exc.message, exc.params, detail=exc.detail), status_code=exc.status) + return JSONResponse(error_body(exc.code, exc.message, exc.params), status_code=exc.status) async def _http_exception_handler(request: Request, exc: StarletteHTTPException): diff --git a/local_backend/routers/business_day.py b/local_backend/routers/business_day.py index fce8ba8..09b5d38 100644 --- a/local_backend/routers/business_day.py +++ b/local_backend/routers/business_day.py @@ -49,19 +49,11 @@ def open_business_day( # Gate: admin lock (already enforced or pending) if license_state.get("locked") or license_state.get("lock_pending"): - raise XeniaError("license.locked", detail={ - "code": "SYSTEM_LOCKED", - "message": "Το σύστημα έχει κλειδωθεί από διαχειριστή. Επικοινωνήστε με την υποστήριξη.", - }) + raise XeniaError("license.locked") # Gate: license expired and expiry grace period also over if not license_state.get("licensed", True): - expires_at = license_state.get("expires_at", "") - raise XeniaError("license.expired", detail={ - "code": "LICENSE_EXPIRED", - "message": "Η άδεια χρήσης έχει λήξει. Ανανεώστε την άδεια ή επικοινωνήστε με την υποστήριξη.", - "expires_at": expires_at, - }) + raise XeniaError("license.expired") opened_at = utcnow() day = BusinessDay(opened_by_id=user.id, notes=body.notes, @@ -97,11 +89,7 @@ def close_business_day( OrderItem.status == "active", ).first() is not None ) - raise XeniaError("business_day.orders_open", detail={ - "message": f"{len(open_orders)} table(s) still open, {with_pending} with unpaid items.", - "open_orders": len(open_orders), - "partially_paid": with_pending, - }, open_orders=len(open_orders), partially_paid=with_pending) + raise XeniaError("business_day.orders_open", open_orders=len(open_orders), partially_paid=with_pending) now = utcnow() diff --git a/local_backend/tests/test_errors.py b/local_backend/tests/test_errors.py index 02aae41..9dee08b 100644 --- a/local_backend/tests/test_errors.py +++ b/local_backend/tests/test_errors.py @@ -110,17 +110,3 @@ def test_backend_code_raises_codes_not_http_exceptions(): for n, line in enumerate(p.read_text(encoding="utf-8").splitlines(), 1) if re.search(r"\bHTTPException\s*\(", line)] assert found == [], "use XeniaError (core/errors.py) instead: " + ", ".join(found) - - -def test_a_code_can_keep_a_v1_shaped_detail(): - app = FastAPI() - install_error_handlers(app) - - @app.get("/x") - def x(): - raise XeniaError("business_day.orders_open", open_orders=2, partially_paid=1, - detail={"message": "2 tables open", "open_orders": 2, "partially_paid": 1}) - - body = TestClient(app).get("/x").json() - assert body["error"]["code"] == "business_day.orders_open" and body["error"]["params"] == {"open_orders": 2, "partially_paid": 1} - assert body["detail"]["open_orders"] == 2 diff --git a/manager_dashboard/src/App.jsx b/manager_dashboard/src/App.jsx index ca03e83..6c43ab7 100644 --- a/manager_dashboard/src/App.jsx +++ b/manager_dashboard/src/App.jsx @@ -13,10 +13,10 @@ import LoginPage from './pages/LoginPage' import SetupWizard from './pages/SetupWizard' // Operation -import DashboardPage from './pages/DashboardPage' +import OverviewPage from './pages/overview/OverviewPage' import TablesPage from './pages/TablesPage' import OrderDetailPage from './pages/OrderDetailPage' -import OnlineOrdersPage from './pages/OnlineOrdersPage' +import OnlineOrdersPage from './pages/online/OnlineOrdersPage' import FeesPage from './pages/online/FeesPage' import QrCodesPage from './pages/online/QrCodesPage' @@ -146,7 +146,7 @@ export default function App() { } /> {/* ── Operation ── */} - } /> + } /> } /> } /> } /> diff --git a/manager_dashboard/src/api/client.js b/manager_dashboard/src/api/client.js index 740e594..2887734 100644 --- a/manager_dashboard/src/api/client.js +++ b/manager_dashboard/src/api/client.js @@ -25,15 +25,4 @@ export default client // ── Online Orders (Xenia Connect) ───────────────────────────────────────────── -export const getIncomingOrders = () => client.get('/api/connect/orders/incoming') -export const getActiveOrders = () => client.get('/api/connect/orders?status=active') -export const getOrderHistory = () => client.get('/api/connect/orders?status=history') - -export const acceptOnlineOrder = (id) => - client.post(`/api/connect/orders/${id}/accept`) - -export const rejectOnlineOrder = (id, reason) => - client.post(`/api/connect/orders/${id}/reject`, { reason }) - -export const updateOnlineOrderStatus = (id, status) => - client.post(`/api/connect/orders/${id}/status`, { status }) +export const getIncomingOrders = () => client.get('/api/connect/orders/incoming') // the sidebar's badge diff --git a/manager_dashboard/src/components/WorkdaySummaryModal.jsx b/manager_dashboard/src/components/WorkdaySummaryModal.jsx deleted file mode 100644 index 78bdd11..0000000 --- a/manager_dashboard/src/components/WorkdaySummaryModal.jsx +++ /dev/null @@ -1,907 +0,0 @@ -import { useState } from 'react' -import { useQuery } from '@tanstack/react-query' -import toast from 'react-hot-toast' -import client from '../api/client' - -// ── Helpers ────────────────────────────────────────────────────────────────── - -function fmt(n) { - if (n == null) return '—' - return n.toLocaleString('el-GR', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ' €' -} - -function fmtTime(iso) { - if (!iso) return '—' - return new Date(iso).toLocaleTimeString('el-GR', { hour: '2-digit', minute: '2-digit' }) -} - -function fmtDateTime(iso) { - if (!iso) return '—' - const d = new Date(iso) - return d.toLocaleString('el-GR', { day: '2-digit', month: '2-digit', hour: '2-digit', minute: '2-digit' }) -} - -const MANAGER_ROLES = new Set(['superadmin', 'owner', 'store_manager', 'staff_manager']) -function roleBadge(role) { - if (MANAGER_ROLES.has(role)) { - return { label: 'Διευθυντής', bg: '#ede9fe', color: '#6d28d9' } - } - return { label: 'Σερβιτόρος', bg: '#e0f2fe', color: '#0369a1' } -} - -// All payment methods with their display config -const PAY_METHODS = [ - { key: 'cash', label: 'Μετρητά', color: '#16a34a', bg: '#dcfce7' }, - { key: 'card', label: 'Κάρτα', color: '#2563eb', bg: '#dbeafe' }, - { key: 'transfer', label: 'Τρ. Μεταφ.', color: '#7c3aed', bg: '#ede9fe' }, - { key: 'treat', label: 'Κεράστηκε', color: '#b45309', bg: '#fef3c7' }, - { key: 'other', label: 'Άλλο', color: '#6b7280', bg: '#f3f4f6' }, -] - -// ── Sub-components ──────────────────────────────────────────────────────────── - -function TabBtn({ label, active, onClick, badge, warn }) { - return ( - - ) -} - -function StatPill({ label, value, accent = '#374151' }) { - return ( -
- {label} - {value} -
- ) -} - -function SectionTitle({ children }) { - return ( -
{children}
- ) -} - -function PaymentBar({ w, total }) { - if (!total) return null - const bars = PAY_METHODS.filter(m => (w[m.key] || 0) > 0) - if (bars.length === 0) return null - return ( -
-
- {bars.map(m => ( -
- ))} -
-
- {bars.map(m => ( - - ● {m.label} {fmt(w[m.key])} - - ))} -
-
- ) -} - -// ── Tabs ────────────────────────────────────────────────────────────────────── - -function FinancialRow({ label, value, sub, accent, warn, indent = false }) { - return ( -
- - {warn && ⚠}{label} - -
- - {value} - - {sub &&
{sub}
} -
-
- ) -} - -function OverviewTab({ data }) { - const waiters = data.waiters.filter(w => w.role === 'waiter') - - return ( -
- {/* Top stats */} -
- - - - -
- - {/* Hours */} -
-
-
ΑΝΟΙΓΜΑ
-
{fmtDateTime(data.opened_at)}
-
-
-
ΚΛΕΙΣΙΜΟ
-
- {data.closed_at ? fmtDateTime(data.closed_at) : Ημέρα Ενεργή} -
-
-
- - {/* Full P&L */} -
- {/* REVENUE */} -
- Έσοδα - - {data.tabbed_revenue > 0 && ( - - )} - -
- - {/* COGS */} -
- Κόστος Πωληθέντων (COGS) - - {data.cogs_has_gap && ( - - )} - = 0 ? '#16a34a' : '#dc2626'} - warn={data.cogs_has_gap} - sub={data.cogs_has_gap ? 'Μερικό — υπάρχουν αντ. χωρίς κόστος' : undefined} - /> -
- - {/* LABOR */} -
- Μισθοδοσία - - {data.labor_untracked_shifts > 0 && ( - - )} -
- - {/* WASTE */} - {(data.waste_item_count > 0) && ( -
- Αποβλήτα - -
- )} - - {/* EXPENSES */} - {data.expenses_total > 0 && ( -
- Έξοδα (σήμερα) - - - {data.expenses_due > 0 && ( - - )} -
- )} - - {/* NET */} -
-
-
-
- Εκτιμώμενο Καθαρό Αποτέλεσμα -
- {data.net_has_unknowns && ( -
- ⚠ Μερικό — υπάρχουν άγνωστα κόστη -
- )} -
-
= 0 ? '#16a34a' : '#dc2626', - fontVariantNumeric: 'tabular-nums', - }}> - {fmt(data.net_estimate)} -
-
-
-
- - {/* Payment breakdown */} -
- Κατανομή Πληρωμών -
- {(() => { - const totals = { cash: 0, card: 0, transfer: 0, treat: 0, other: 0 } - for (const w of data.waiters) { - for (const k of Object.keys(totals)) totals[k] += (w[k] || 0) - } - return - })()} -
-
- - {/* Cash reconciliation summary (if counted) */} - {data.store_closing_cash != null && ( -
- Ταμείο -
- - - -
-
- )} -
- ) -} - -function WaitersTab({ data }) { - const [expanded, setExpanded] = useState(null) - - // Fixed column widths for the collapsed summary row - const colPx = { orders: 88, tables: 88, items: 80, collected: 104 } - - return ( -
- {data.waiters.length === 0 && ( -
Δεν βρέθηκαν σερβιτόροι
- )} - {data.waiters.map(w => { - const badge = roleBadge(w.role) - const isOpen = expanded === w.waiter_id - - // Compute current cash in drawer: starting_cash + collected so far - const drawerNow = (w.starting_cash ?? 0) + (w.total_collected ?? 0) - - return ( -
- - - {isOpen && ( -
- {/* Row 1: shift timing + payroll */} -
- {[ - { label: 'ΕΝΑΡΞΗ ΒΑΡΔΙΑΣ', value: fmtTime(w.shift_started_at), color: '#111315' }, - { - label: 'ΛΗΞΗ ΒΑΡΔΙΑΣ', - value: w.shift_ended_at ? fmtTime(w.shift_ended_at) : 'Βάρδια Ενεργή', - color: w.shift_ended_at ? '#111315' : '#16a34a', - }, - { - label: 'ΜΙΣΘΟΣ / ΩΡΑ', - value: w.hourly_rate_snapshot != null ? fmt(w.hourly_rate_snapshot) : '—', - color: '#111315', - }, - { - label: 'ΜΙΣΘΟΣ (εως τώρα)', - value: w.shift_pay != null ? fmt(w.shift_pay) : 'Δεν παρακολ.', - color: w.shift_pay != null ? '#059669' : '#9ca3af', - }, - ].map(cell => ( -
-
{cell.label}
-
{cell.value}
-
- ))} -
- {/* Row 2: cash + collections */} -
- {[ - { - label: 'ΑΡΧΙΚΑ ΜΕΤΡΗΤΑ', - value: w.starting_cash != null ? fmt(w.starting_cash) : '—', - color: '#111315', - }, - { - label: 'ΤΑΜΕΙΟ ΤΩΡΑ', - value: fmt(drawerNow), - color: '#3758c9', - }, - { - label: 'ΑΝΤΙΚ. ΕΙΣΠΡ.', - value: w.items_paid, - color: '#111315', - }, - { - label: 'ΕΞ. ΤΡΑΠΕΖΙΩΝ', - value: w.tables_served ?? 0, - color: '#111315', - }, - ].map(cell => ( -
-
{cell.label}
-
{cell.value}
-
- ))} -
- -
- )} -
- ) - })} -
- ) -} - -function ZonesTab({ data }) { - const maxRev = Math.max(...data.zones.map(z => z.revenue), 1) - return ( -
- {data.zones.length === 0 && ( -
Δεν βρέθηκαν ζώνες
- )} - {data.zones.map(z => ( -
-
-
- {z.group_name} - {fmt(z.revenue)} -
- -
-
-
- -
-
- ΠΑΡΑΓΓΕΛΙΕΣ - {z.orders} -
-
- ΑΝΤΙΚΕΙΜΕΝΑ - {z.items} -
- {z.orders > 0 && ( -
- Μ.Ο./ΠΑΡΑΓ. - {fmt(z.revenue / z.orders)} -
- )} -
-
- ))} -
- ) -} - -function PrintersTab({ data }) { - return ( -
- {data.printers.length === 0 && ( -
Δεν βρέθηκαν δεδομένα εκτύπωσης
- )} - {data.printers.map(p => { - const successRate = p.jobs > 0 ? Math.round((p.success / p.jobs) * 100) : 0 - return ( -
-
-
- - - - - -
-
-
{p.printer_name}
-
{p.ip_address}
-
-
-
{fmt(p.items_value)}
-
αξία εκτυπ.
-
- = 80 ? '#fef9c3' : '#fee2e2', - color: successRate === 100 ? '#16a34a' : successRate >= 80 ? '#a16207' : '#dc2626', - }}>{successRate}% -
- -
-
-
-
-
-
- -
-
ΕΡΓΑΣΙΕΣ {p.jobs}
-
ΕΠΙΤΥΧΕΙΣ {p.success}
- {p.failed > 0 &&
ΑΠΟΤΥΧΕΣ {p.failed}
} -
-
- ) - })} -
- ) -} - -function CashReconciliationTab({ data, storeCash, onStoreCashChange }) { - const expected = data.store_expected_closing ?? 0 - const counted = storeCash !== '' ? parseFloat(storeCash) : null - const discrepancy = counted != null ? counted - expected : null - const isShort = discrepancy != null && discrepancy < -0.005 - const isOver = discrepancy != null && discrepancy > 0.005 - const isClean = discrepancy != null && !isShort && !isOver - - return ( -
-
-
Σύνοψη Εισπράξεων Βάρδιας
-
-
- Σύνολο εισπράξεων σερβιτόρων - {fmt(data.total_waiter_collected)} -
- {data.store_opening_cash != null && ( -
- Αρχικό ταμείο - {fmt(data.store_opening_cash)} -
- )} -
- Αναμενόμενο ταμείο τώρα - {fmt(expected)} -
-
-
- -
- - onStoreCashChange(e.target.value)} - placeholder="0.00" - style={{ - width: '100%', padding: '10px 14px', border: '1.5px solid #e5e7eb', - borderRadius: 10, fontSize: 18, fontWeight: 700, color: '#111315', - outline: 'none', boxSizing: 'border-box', background: 'white', - }} - /> -
- - {discrepancy != null && ( -
-
- {isClean && '✓ Ταμείο εντάξει'} - {isShort && `⚠ Έλλειμμα ${fmt(Math.abs(discrepancy))}`} - {isOver && `⚠ Πλεόνασμα ${fmt(Math.abs(discrepancy))}`} -
-
- {isClean && 'Το φυσικό ταμείο συμφωνεί με τις καταγεγραμμένες εισπράξεις.'} - {isShort && `Το ταμείο έχει ${fmt(Math.abs(discrepancy))} λιγότερα από το αναμενόμενο. Το κενό δεν αποδίδεται σε κάποιον σερβιτόρο συγκεκριμένα.`} - {isOver && `Το ταμείο έχει ${fmt(Math.abs(discrepancy))} περισσότερα από το αναμενόμενο.`} -
-
- )} - - {storeCash === '' && ( -

- Αν παραλείψετε τη μέτρηση, η επαλήθευση δεν θα καταγραφεί. -

- )} -
- ) -} - -function ChecksTab({ data, onForceClose, closing, isOpen }) { - const { checks } = data - const allGood = checks.open_orders === 0 - const hasUnpaid = checks.with_unpaid_items > 0 - const hasActiveShifts = checks.active_shifts > 0 - - return ( -
- -
0 ? '#fecaca' : '#bbf7d0'}`, - borderRadius: 12, padding: '16px 18px', background: checks.open_orders > 0 ? '#fff5f5' : '#f0fdf4', - display: 'flex', alignItems: 'flex-start', gap: 12, - }}> -
0 ? '#fee2e2' : '#dcfce7', - display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 15, - }}> - {checks.open_orders > 0 ? '⚠️' : '✓'} -
-
-
Ανοιχτά Τραπέζια
- {checks.open_orders > 0 ? ( -
- {checks.open_orders} τραπέζια ακόμα ανοιχτά - {hasUnpaid && ` · ${checks.with_unpaid_items} με απλήρωτα αντικείμενα`} -
- ) : ( -
Όλα τα τραπέζια έχουν κλείσει
- )} -
-
- -
-
- {hasActiveShifts ? '⏳' : '✓'} -
-
-
Ενεργές Βάρδιες
- {hasActiveShifts ? ( -
- {checks.active_shifts} βάρδι{checks.active_shifts === 1 ? 'α' : 'ες'} ακόμα ενεργ{checks.active_shifts === 1 ? 'ή' : 'ές'} — θα κλείσουν αυτόματα -
- ) : ( -
Δεν υπάρχουν ενεργές βάρδιες
- )} -
-
- - {allGood ? ( -
- ✅ -
- Ο έλεγχος πέρασε — η ημέρα είναι έτοιμη να κλείσει. -
-
- ) : hasUnpaid ? ( -
-
- Προσοχή: Υπάρχουν απλήρωτα αντικείμενα. Αν κλείσετε αναγκαστικά, τα απλήρωτα ποσά δεν θα καταγραφούν στις αναφορές. -
-
- ) : ( -
-
- Υπάρχουν ανοιχτά τραπέζια χωρίς απλήρωτα αντικείμενα. Θα κλείσουν αυτόματα. -
-
- )} - - {isOpen && ( - - )} -
- ) -} - -// ── Main modal ──────────────────────────────────────────────────────────────── - -export default function WorkdaySummaryModal({ dayId, onClose, showCloseAction = false, onDayClosed }) { - const [tab, setTab] = useState('overview') - const [closing, setClosing] = useState(false) - const [storeCash, setStoreCash] = useState('') // Phase 2E: store cash count - - const { data, isLoading, error } = useQuery({ - queryKey: ['workday-summary', dayId ?? 'current'], - queryFn: () => client.get('/api/business-day/summary' + (dayId ? `?day_id=${dayId}` : '')).then(r => r.data), - refetchInterval: showCloseAction ? 15_000 : false, - }) - - async function handleClose(force = false) { - setClosing(true) - try { - const payload = { force } - if (storeCash !== '') payload.store_closing_cash = parseFloat(storeCash) - await client.post('/api/business-day/close', payload) - onDayClosed?.() - } catch (e) { - const detail = e.response?.data?.detail - if (e.response?.status === 409 && detail?.open_orders) { - setTab('checks') - } else { - toast.error(typeof detail === 'string' ? detail : 'Σφάλμα κλεισίματος') - } - } finally { - setClosing(false) - } - } - - const tabs = [ - { id: 'overview', label: 'Επισκόπηση' }, - { id: 'waiters', label: 'Προσωπικό', badge: data?.waiters?.length }, - { id: 'zones', label: 'Ζώνες', badge: data?.zones?.length }, - { id: 'printers', label: 'Εκτυπωτές', badge: data?.printers?.length }, - ...(showCloseAction ? [ - { id: 'cash', label: 'Ταμείο' }, - { - id: 'checks', label: 'Έλεγχοι', - badge: data?.checks ? (data.checks.open_orders + data.checks.active_shifts) : null, - warn: data?.checks?.with_unpaid_items > 0, - }, - ] : []), - ] - - const isOpen = data?.status === 'open' - - return ( -
{ if (e.target === e.currentTarget) onClose() }} - > -
- {/* Header */} -
-
-
- - - - - -
-
-
- {showCloseAction ? 'Κλείσιμο Εργάσιμης Ημέρας' : 'Στατιστικά Ημέρας'} -
- {data && ( -
- {data.status === 'open' - ? ● Ημέρα Ενεργή - : Κλειστή - } - {' · '}Άνοιγμα {fmtDateTime(data?.opened_at)} -
- )} -
- -
- -
- {tabs.map(t => ( - setTab(t.id)} badge={t.badge} warn={t.warn} /> - ))} -
-
- - {/* Body */} -
- {isLoading && ( -
Φόρτωση…
- )} - {error && ( -
Σφάλμα φόρτωσης δεδομένων
- )} - {data && ( - <> - {tab === 'overview' && } - {tab === 'waiters' && } - {tab === 'zones' && } - {tab === 'printers' && } - {tab === 'cash' && ( - - )} - {tab === 'checks' && ( - handleClose(data.checks.open_orders > 0)} - closing={closing} - /> - )} - - )} -
- - {/* Footer — only shown when in close-flow and not already on checks tab */} - {showCloseAction && data && tab !== 'checks' && ( -
- - {tab !== 'cash' ? ( - - ) : ( - - )} -
- )} -
-
- ) -} diff --git a/manager_dashboard/src/pages/DashboardPage.jsx b/manager_dashboard/src/pages/DashboardPage.jsx deleted file mode 100644 index 8984b03..0000000 --- a/manager_dashboard/src/pages/DashboardPage.jsx +++ /dev/null @@ -1,2768 +0,0 @@ -import { useState, useEffect, useContext, useRef } from 'react' -import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' -import { useNavigate } from 'react-router-dom' -import toast from 'react-hot-toast' -import client from '../api/client' -import Badge from '../ui/Badge' -import { ConfirmModal } from '../ui/Modal' -import { LicenseContext } from '../layouts/AppLayout' -import WorkdaySummaryModal from '../components/WorkdaySummaryModal' - - -// ─── Helpers ────────────────────────────────────────────────────────────────── - -function fmtTime(iso) { - if (!iso) return '—' - return new Date(iso).toLocaleTimeString('el-GR', { hour: '2-digit', minute: '2-digit' }) -} - -function fmtDuration(isoStart) { - if (!isoStart) return '—' - const mins = Math.floor((Date.now() - new Date(isoStart).getTime()) / 60000) - if (mins < 60) return `${mins}λ` - const h = Math.floor(mins / 60) - const m = mins % 60 - return m === 0 ? `${h}ω` : `${h}ω ${m}λ` -} - -function fmtEuro(n) { - return '€' + parseFloat(n || 0).toFixed(2) -} - -function orderTotal(items = []) { - return items - .filter(i => i.status !== 'cancelled') - .reduce((s, i) => s + ((i.unit_price ?? 0) + (i.price_adjustment ?? 0)) * i.quantity, 0) -} - -function avatarColor(name) { - const palette = ['#3758c9', '#7a44c9', '#2f9e5e', '#d94b26', '#8a6d2b', '#0d7a8a', '#c93775'] - let h = 0 - for (let i = 0; i < name.length; i++) h = (h * 31 + name.charCodeAt(i)) >>> 0 - return palette[h % palette.length] -} - -function Avatar({ name, avatarUrl, size = 36 }) { - if (avatarUrl) { - return ( - {name} - ) - } - const parts = (name || '?').trim().split(' ') - const initials = (parts[0][0] + (parts[1]?.[0] || '')).toUpperCase() - return ( -
{initials}
- ) -} - -// ─── Table color tokens ──────────────────────────────────────────────────────── - -const TABLE_COLORS = { - open: { bg: '#bbf7d0', border: '#4ade80', dot: '#16a34a', text: '#14532d', label: 'Ανοιχτό' }, - partially_paid: { bg: '#e9d5ff', border: '#a855f7', dot: '#7c3aed', text: '#4c1d95', label: 'Μερική πληρ.' }, - free: { bg: '#f4f4f2', border: '#dfe2e6', dot: '#8a9099', text: '#5a6169', label: 'Ελεύθερο' }, -} - -// ─── Business Day / Shift modals ─────────────────────────────────────────────── - -function StartShiftModal({ waiters, onClose, onStart }) { - const [waiterId, setWaiterId] = useState('') - const [cash, setCash] = useState('') - const [busy, setBusy] = useState(false) - - async function submit() { - if (!waiterId) { toast.error('Επιλέξτε σερβιτόρο'); return } - setBusy(true) - try { - await onStart(Number(waiterId), cash ? parseFloat(cash) : null) - onClose() - } catch (e) { - toast.error(e.response?.data?.detail || 'Σφάλμα εκκίνησης βάρδιας') - } finally { - setBusy(false) - } - } - - return ( -
{ if (e.target === e.currentTarget) onClose() }}> -
-
-

Έναρξη Βάρδιας

- -
-
- - -
-
- - setCash(e.target.value)} - className="h-10 w-full rounded-lg border border-gray-300 bg-white px-3 text-sm text-gray-800 focus:outline-none" /> -
-
- - -
-
-
- ) -} - -function CloseConfirmModal({ details, onClose, onConfirm, busy }) { - if (!details.partially_paid) { - return ( -
{ if (e.target === e.currentTarget) onClose() }}> -
-

Κλείσιμο Ημέρας

-
-

- {details.open_orders} {details.open_orders === 1 ? 'τραπέζι είναι ακόμα ανοιχτό' : 'τραπέζια είναι ακόμα ανοιχτά'} -

-

Κανένα δεν έχει εκκρεμείς χρεώσεις. Θέλετε να κλείσουν όλα και να κλείσει η ημέρα;

-
-
- - -
-
-
- ) - } - return ( -
{ if (e.target === e.currentTarget) onClose() }}> -
-
-
- ! -
-

Εκκρεμείς Πληρωμές

-
-
-

- {details.open_orders} {details.open_orders === 1 ? 'ανοιχτό τραπέζι' : 'ανοιχτά τραπέζια'}, - από τα οποία {details.partially_paid} έχ{details.partially_paid === 1 ? 'ει' : 'ουν'} εκκρεμείς πληρωμές. -

-

Αν κλείσετε αναγκαστικά, τα απλήρωτα ποσά θα χαθούν και δεν θα καταγραφούν στις αναφορές.

-
-
- Επιλέξτε Ακύρωση για να χειριστείτε χειροκίνητα τα εκκρεμή τραπέζια πριν κλείσετε την ημέρα. -
-
- - -
-
-
- ) -} - -// ─── Order quick-view modal ──────────────────────────────────────────────────── - -function OrderQuickModal({ orderId, tableName, onClose, onOpenFull }) { - const qc = useQueryClient() - - const { data: order, isLoading } = useQuery({ - queryKey: ['order', orderId], - queryFn: () => client.get(`/api/orders/${orderId}`).then(r => r.data), - enabled: !!orderId, - }) - - const { data: waiters = [] } = useQuery({ - queryKey: ['waiters'], - queryFn: () => client.get('/api/waiters/').then(r => r.data), - staleTime: 60_000, - }) - - const { data: printers = [] } = useQuery({ - queryKey: ['printers'], - queryFn: () => client.get('/api/system/printers').then(r => r.data), - staleTime: 60_000, - }) - - const { data: rawPriceEvents = [] } = useQuery({ - queryKey: ['price-events', orderId], - queryFn: () => client.get(`/api/pricing/events/order/${orderId}`).then(r => r.data), - enabled: !!orderId, - staleTime: 30_000, - }) - const priceEventsMap = rawPriceEvents.reduce((acc, ev) => { - if (!acc[ev.order_item_id]) acc[ev.order_item_id] = [] - acc[ev.order_item_id].push(ev) - return acc - }, {}) - - const [confirmAction, setConfirmAction] = useState(null) - const [printCancelConfirm, setPrintCancelConfirm] = useState(null) // { type: 'item'|'order', payload? } - const [printerId, setPrinterId] = useState('') - - const waiterMap = Object.fromEntries(waiters.map(w => [w.id, w.nickname || w.full_name || w.username])) - - const invalidate = () => { - qc.invalidateQueries({ queryKey: ['order', orderId] }) - qc.invalidateQueries({ queryKey: ['orders-active'] }) - } - - const payItems = useMutation({ - mutationFn: (item_ids) => client.post(`/api/orders/${orderId}/pay`, { item_ids }), - onSuccess: () => { toast.success('Πληρώθηκε'); invalidate() }, - onError: () => toast.error('Σφάλμα πληρωμής'), - }) - - const cancelItem = useMutation({ - mutationFn: ({ itemId, printCancellation }) => - client.delete(`/api/orders/${orderId}/items/${itemId}?print_cancellation=${printCancellation}`), - onSuccess: () => { toast.success('Αντικείμενο ακυρώθηκε'); invalidate() }, - onError: () => toast.error('Σφάλμα ακύρωσης'), - }) - - const cancelOrder = useMutation({ - mutationFn: ({ printCancellation }) => - client.delete(`/api/orders/${orderId}?print_cancellation=${printCancellation}`), - onSuccess: () => { toast.success('Παραγγελία ακυρώθηκε'); invalidate(); onClose() }, - onError: () => toast.error('Σφάλμα ακύρωσης παραγγελίας'), - }) - - const closeOrder = useMutation({ - mutationFn: () => client.post(`/api/orders/${orderId}/close`), - onSuccess: () => { toast.success('Παραγγελία έκλεισε'); invalidate(); onClose() }, - onError: () => toast.error('Σφάλμα κλεισίματος'), - }) - - const printOrder = useMutation({ - mutationFn: (pid) => client.post(`/api/orders/${orderId}/print`, { printer_id: pid }), - onSuccess: () => toast.success('Αποστολή στον εκτυπωτή…'), - onError: () => toast.error('Σφάλμα εκτύπωσης'), - }) - - function handleConfirm() { - if (!confirmAction) return - const type = confirmAction.type - const payload = confirmAction.payload - setConfirmAction(null) - if (type === 'cancelItem') { - setPrintCancelConfirm({ type: 'item', payload }) - return - } - if (type === 'cancelOrder') { - setPrintCancelConfirm({ type: 'order' }) - return - } - if (type === 'closeOrder') closeOrder.mutate() - } - - function executeCancelWithPrint(printCancellation) { - if (!printCancelConfirm) return - if (printCancelConfirm.type === 'item') { - cancelItem.mutate({ itemId: printCancelConfirm.payload, printCancellation }) - } else { - cancelOrder.mutate({ printCancellation }) - } - setPrintCancelConfirm(null) - } - - const total = order ? orderTotal(order.items) : 0 - const activeItems = order ? order.items.filter(i => i.status === 'active') : [] - const isOpen = order ? ['open', 'partially_paid'].includes(order.status) : false - - return ( -
{ if (e.target === e.currentTarget) onClose() }} - > -
- {/* Modal header */} -
-
-
- Τραπέζι {tableName} -
- {order && ( -
- Παραγγελία #{order.id} · από {fmtTime(order.opened_at)} · {fmtDuration(order.opened_at)} -
- )} -
-
- {order && ( - {fmtEuro(total)} - )} - {order && ( - - )} - -
-
- - {/* Scrollable body */} -
- {isLoading && ( -
Φόρτωση…
- )} - - {order && ( - <> - {/* Waiters row */} - {order.waiters.length > 0 && ( -
- Προσωπικό -
- {order.waiters.map(w => ( - {waiterMap[w.waiter_id] || `#${w.waiter_id}`} - ))} -
-
- )} - - {/* Items list */} -
- {order.items.length === 0 && ( -
Κανένα αντικείμενο.
- )} - {order.items.map(item => { - const itemEvents = priceEventsMap[item.id] ?? [] - const hasPriceAdj = !!(item.price_adjustment && item.price_adjustment !== 0) - const isDealItem = !!item.deal_id - const modifierEvents = itemEvents.filter(ev => ev.event_type === 'modifier_applied') - const discountEvents = itemEvents.filter(ev => ev.event_type === 'waiter_discount') - return ( -
-
-
-
- {item.product?.name ?? `#${item.product_id}`} - ×{item.quantity} - {isDealItem && ( - ΔΩΡΕΑΝ - )} - {modifierEvents.length > 0 && ( - - {modifierEvents[0].modifier_name || 'Τροποποιητής'} - - )} - {discountEvents.length > 0 && ( - - Έκπτωση - - )} -
- {item.notes &&
{item.notes}
} - {item.paid_by && ( -
- Πληρώθηκε -
- )} -
-
- {fmtEuro(((item.unit_price ?? 0) + (item.price_adjustment ?? 0)) * item.quantity)} - {isOpen && item.status === 'active' && ( - <> - - - - )} -
-
- {itemEvents.filter(ev => ['modifier_applied','waiter_discount','free_item_added'].includes(ev.event_type)).map((ev, ei) => { - const evColor = ev.event_type === 'waiter_discount' ? '#7c3aed' : ev.event_type === 'free_item_added' ? '#16a34a' : '#2563eb' - const evLabel = ev.modifier_name || ev.deal_name || (ev.event_type === 'waiter_discount' ? 'Έκπτωση' : ev.event_type === 'free_item_added' ? 'Δωρεάν' : ev.event_type) - return ( -
- ↳ - {evLabel} - {ev.delta_amount != null && {ev.delta_amount > 0 ? '+' : ''}{ev.delta_amount.toFixed(2)} €} - {ev.price_after != null && → {ev.price_after.toFixed(2)} €} -
- ) - })} -
- ) - })} -
- - )} -
- - {/* Footer actions */} - {order && ( -
- {isOpen && activeItems.length > 0 && ( - - )} - {isOpen && ( - <> - - - - )} - {printers.length > 0 && ( -
- - -
- )} - -
- )} -
- - {confirmAction && ( - setConfirmAction(null)} - /> - )} - - {printCancelConfirm && ( -
-
-
🖨️
-

- Εκτύπωση ακύρωσης; -

-

- Θέλετε να σταλεί ακυρωτικό ticket στον εκτυπωτή; -

-
- - -
-
-
- )} -
- ) -} - -// ─── KPI Card ───────────────────────────────────────────────────────────────── - -function KpiCard({ label, value, sub, accent = '#3758c9', pct, private: isPrivate }) { - return ( -
-
{label}
-
{value}
- {sub &&
{sub}
} - {pct != null && ( -
-
-
- )} -
- ) -} - -// ─── Mini table chip ────────────────────────────────────────────────────────── - -function TableChip({ name, status, amount, onClick }) { - const c = TABLE_COLORS[status] || TABLE_COLORS.free - return ( - - ) -} - -// ─── Shifts card ────────────────────────────────────────────────────────────── - -// ─── Shift Review Modal (Overview + Details + optional close flow) ───────────── - -const SWATCH = { cash: '#2f9e5e', card: '#3758c9' } - -function initials(name = '') { - const parts = name.trim().split(/\s+/) - if (parts.length >= 2) return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase() - return name.slice(0, 2).toUpperCase() -} - -function fmtDur(ms) { - const totalMin = Math.round(ms / 60000) - const h = Math.floor(totalMin / 60) - const m = totalMin % 60 - return h > 0 ? `${h}ω ${m}λ` : `${m}λ` -} - -// Embedded detail views (extracted from ShiftDetailModal but self-contained here) -function classifyItem(item, shiftWaiterId) { - if (item.status === 'cancelled') - return { key: 'cancelled', label: 'Ακυρώθηκε', dot: '#dc2626', bg: '#fef2f2', border: '#fecaca', text: '#991b1b' } - const orderedByMe = item.added_by_id === shiftWaiterId - const paidToMe = item.paid_by_id === shiftWaiterId - const isPaid = item.status === 'paid' - if (orderedByMe && paidToMe && isPaid) - return { key: 'both', label: 'Πλήρης', dot: '#16a34a', bg: '#f0fdf4', border: '#bbf7d0', text: '#15803d' } - if (!orderedByMe && paidToMe && isPaid) - return { key: 'paid', label: 'Μόνο Πληρώθηκε', dot: '#2563eb', bg: '#eff6ff', border: '#bfdbfe', text: '#1d4ed8' } - if (orderedByMe && isPaid && !paidToMe) - return { key: 'ordered', label: 'Μόνο Παρήγγειλε',dot: '#ca8a04', bg: '#fefce8', border: '#fef08a', text: '#854d0e' } - if (orderedByMe && !isPaid) - return { key: 'unpaid', label: 'Ανοιχτό', dot: '#ea580c', bg: '#fff7ed', border: '#fed7aa', text: '#c2410c' } - return { key: 'anomaly', label: 'Πρόβλημα', dot: '#dc2626', bg: '#fef2f2', border: '#fecaca', text: '#b91c1c' } -} - -const DETAIL_FILTER_STATUS = [ - { key: 'all', label: 'Όλα' }, - { key: 'both', label: 'Πλήρης' }, - { key: 'paid', label: 'Μόνο Πληρώθηκε' }, - { key: 'ordered', label: 'Μόνο Παρήγγειλε' }, - { key: 'unpaid', label: 'Ανοιχτό' }, - { key: 'cancelled', label: 'Ακυρώθηκε' }, -] -const DETAIL_FILTER_PAYMENT = [ - { key: 'any', label: 'Κάθε τρόπος' }, - { key: 'cash', label: 'Μετρητά' }, - { key: 'card', label: 'Κάρτα' }, -] - -function DetailItemRow({ item, shiftWaiterId }) { - const c = classifyItem(item, shiftWaiterId) - const isCancelled = item.status === 'cancelled' - const method = item.payment_method || 'cash' - return ( -
-
-
-
- - {item.product_name} - ×{item.quantity} - - - {fmtEuro(item.subtotal)} - -
-
- - Παρήγγειλε: {item.added_by_name ?? '—'} - - {!isCancelled && ( - - Πληρώθηκε: {item.paid_by_name ?? '—'} - {item.payment_method && ( - {method === 'card' ? 'Κάρτα' : 'Μετρητά'} - )} - - )} -
-
- {c.label} -
-
-
- ) -} - -function DetailOrderGroup({ order, shiftWaiterId, statusFilter, paymentFilter }) { - const visibleItems = order.items.filter(item => { - const statusOk = statusFilter === 'all' || classifyItem(item, shiftWaiterId).key === statusFilter - const payOk = paymentFilter === 'any' || !item.payment_method - ? (paymentFilter === 'any' || (paymentFilter === 'cash' && item.status === 'paid')) - : (item.payment_method || 'cash') === paymentFilter - // If status filter is cancelled, don't apply payment filter - const isCancelled = item.status === 'cancelled' - return statusOk && (isCancelled || paymentFilter === 'any' || (item.payment_method || 'cash') === paymentFilter) - }) - if (visibleItems.length === 0) return null - const groupTotal = visibleItems.filter(i => i.status === 'paid').reduce((s, i) => s + i.subtotal, 0) - return ( -
-
-
- Παραγγελία #{order.order_id} - {order.table_name && · {order.table_name}} -
-
- {order.opener_name && ( - - Άνοιξε: {order.opener_name} - {order.opened_at ? {fmtTime(order.opened_at)} : null} - - )} - {groupTotal > 0 && {fmtEuro(groupTotal)}} -
-
- {visibleItems.map(item => ( - - ))} -
- ) -} - -// ─── The main modal ──────────────────────────────────────────────────────────── - -function ShiftReviewModal({ shift, mode, onClose, onConfirm, busy }) { - // mode: 'stats' (view only) | 'close' (end shift flow) - const [screen, setScreen] = useState('overview') // 'overview' | 'details' - const [closeStep, setCloseStep] = useState(1) // 1 = review+notes, 2 = cash handover - const [notes, setNotes] = useState('') - const [countedCash, setCountedCash] = useState('') - const [statusFilter, setStatusFilter] = useState('all') - const [paymentFilter, setPaymentFilter] = useState('any') - - // Fetch live summary (includes orders for details tab + per-shift aggregates) - const { data: summary, isLoading } = useQuery({ - queryKey: ['shift-detail', shift.id], - queryFn: () => client.get(`/api/shifts/${shift.id}/summary`).then(r => r.data), - staleTime: 30 * 1000, - refetchOnWindowFocus: false, - }) - - // Use enriched data from summary when available, fall back to shift prop - const data = summary || shift - const cashSales = data.cash_sales ?? data.total_collected ?? 0 - const cardSales = data.card_sales ?? 0 - const totalRev = cashSales + cardSales - const startingCash = data.starting_cash ?? 0 - const expectedDrawer = startingCash + cashSales - const cashPct = totalRev > 0 ? Math.round((cashSales / totalRev) * 100) : 0 - const cardPct = 100 - cashPct - - // Cash handover discrepancy - const counted = countedCash !== '' ? parseFloat(countedCash) : null - const discrepancy = counted != null ? +(counted - expectedDrawer).toFixed(2) : null - const isShort = discrepancy != null && discrepancy < -0.005 - const isOver = discrepancy != null && discrepancy > 0.005 - const isClean = discrepancy != null && !isShort && !isOver - - // Duration - const startMs = shift.started_at ? new Date(shift.started_at).getTime() : null - const nowMs = Date.now() - const durLabel = startMs ? fmtDur(nowMs - startMs) : '—' - - // Stats from summary - const totalOrders = summary?.orders?.length ?? 0 - const totalItems = summary?.orders?.reduce((s, o) => s + o.items.filter(i => i.status === 'paid').reduce((ss, i) => ss + i.quantity, 0), 0) ?? 0 - const totalTables = summary?.orders ? new Set(summary.orders.filter(o => o.table_id).map(o => o.table_id)).size : 0 - const shiftPay = data.shift_pay - - // Per-hour bars from summary orders - const hourBuckets = {} - if (summary?.orders) { - for (const o of summary.orders) { - for (const item of o.items) { - if (item.status !== 'paid' || !item.paid_at) continue - const h = new Date(item.paid_at).getHours() - hourBuckets[h] = (hourBuckets[h] || 0) + item.subtotal - } - } - } - const hourEntries = Object.entries(hourBuckets).sort((a, b) => a[0] - b[0]) - const maxHourVal = Math.max(...hourEntries.map(([, v]) => v), 1) - - const waiterIdToUse = shift.waiter_id ?? summary?.waiter_id - - // ── Shared header ── - const inits = initials(shift.waiter_name || '') - const color = avatarColor(shift.waiter_name || '') - const isClosing = mode === 'close' && closeStep === 2 - const badgeLabel = mode === 'close' ? (closeStep === 1 ? 'Κλείσιμο' : 'Κλείσιμο') : 'Σε εξέλιξη' - - return ( -
{ if (e.target === e.currentTarget) onClose() }} - > -
- - {/* ── Header ── */} -
-
- {inits} -
-
-
- {shift.waiter_name} - - - {badgeLabel} - -
-
- Βάρδια #{shift.id} -
-
- {/* Screen toggle */} -
- {[ - { key: 'overview', title: 'Επισκόπηση', icon: '▤' }, - { key: 'details', title: 'Λεπτομέρειες', icon: '≡' }, - ].map(({ key, title, icon }) => ( - - ))} -
- -
- - {/* ── Time strip ── */} -
- {[ - { key: 'Έναρξη', val: fmtTime(shift.started_at) }, - { key: 'Διάρκεια', val: durLabel }, - { key: mode === 'close' ? 'Τέλος' : 'Τρέχουσα', val: mode === 'close' ? fmtTime(new Date().toISOString()) : fmtTime(new Date().toISOString()), muted: mode !== 'close' }, - ].map(({ key, val, muted }) => ( -
-
{key}
-
{val}
-
- ))} -
- - {/* ── Body ── */} -
- - {/* ══ OVERVIEW SCREEN ══ */} - {screen === 'overview' && ( -
- - {/* Hero: expected drawer */} -
-
-
-
Αναμενόμενο στο ταμείο
-
- € - {expectedDrawer.toFixed(2)} -
-
-
- Αρχικό {fmtEuro(startingCash)}
- + Μετρητά {fmtEuro(cashSales)} -
-
- - {/* 3 tiles */} -
- {[ - { sw: '#9ca3af', label: 'Αρχικό ταμείο', val: fmtEuro(startingCash), sub: 'με τι ξεκίνησε' }, - { sw: SWATCH.cash, label: 'Μετρητά πωλήσεων', val: fmtEuro(cashSales), sub: 'είσπραξη σε μετρητά' }, - { sw: SWATCH.card, label: 'Συνολικός τζίρος', val: fmtEuro(totalRev), sub: 'μετρητά + κάρτα' }, - ].map(t => ( -
-
- - {t.label} -
-
{t.val}
-
{t.sub}
-
- ))} -
- - {/* Payment split bar */} - {totalRev > 0 && ( -
-
- Μέθοδος πληρωμής - σύνολο {fmtEuro(totalRev)} -
-
- {cashPct > 0 &&
} - {cardPct > 0 &&
} -
-
- {[ - { sw: SWATCH.cash, label: 'Μετρητά', amt: fmtEuro(cashSales), pct: `${cashPct}%` }, - { sw: SWATCH.card, label: 'Κάρτα', amt: fmtEuro(cardSales), pct: `${cardPct}%` }, - ].map(l => ( -
- - {l.label} - {l.amt} - {l.pct} -
- ))} -
-
- )} - - {/* Per-hour bars */} - {hourEntries.length > 0 && ( -
-
Πωλήσεις ανά ώρα
-
- {hourEntries.map(([h, v]) => ( -
-
-
{h}
-
- ))} -
-
- )} - - {/* Bottom stats strip */} -
- {[ - { val: String(totalItems), lab: 'Είδη' }, - { val: String(totalTables), lab: 'Τραπέζια' }, - { val: String(totalOrders), lab: 'Παραγγελίες' }, - { val: shiftPay != null ? fmtEuro(shiftPay) : '—', lab: 'Αμοιβή', sub: data.hourly_rate_snapshot ? `${fmtEuro(data.hourly_rate_snapshot)}/ώρα` : null }, - ].map((s, i) => ( -
-
{s.val}
-
{s.lab}
- {s.sub &&
{s.sub}
} -
- ))} -
- - {/* Notes (only shown in close mode before step 2) */} - {mode === 'close' && closeStep === 1 && ( -
-
- Σημειώσεις (προαιρετικό) -
-