feat: initial commit — local services (backend + manager dashboard + waiter PWA)

Includes all work to date:
- local_backend: FastAPI backend with products, orders, tables, shifts, cloud sync
- manager_dashboard: React manager UI with product/category management, reports, settings
- waiter_pwa: React PWA for waiter devices
- Category reparent endpoint and UI
- Waiter domain: local_ip sent on heartbeat, waiter_domain persisted from cloud response
- QR code modal in AppInfoTab for waiter domain
- Product form: number input spinners removed, category pre-selected on new product
- Category row: count badge moved to far right

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 14:04:38 +03:00
co-authored by Claude Sonnet 4.6
commit 8ba8c95ecd
209 changed files with 48017 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import { STATUS_STYLES } from './tokens'
// Unified StatusBadge — replaces both src/components/StatusBadge.jsx
// and the StatusBadge in TablePrimitives.jsx.
//
// Greek labels map to the canonical status keys used across the app.
const LABELS = {
free: 'Ελεύθερο',
open: 'Ανοιχτό',
active: 'Ενεργό',
partially_paid: 'Μερική πληρωμή',
paid: 'Πληρώθηκε',
closed: 'Κλειστό',
'force-closed': 'Αναγκαστικό κλείσιμο',
cancelled: 'Ακυρώθηκε',
completed: 'Ολοκληρώθηκε',
failed: 'Απέτυχε',
success: 'Επιτυχία',
}
export default function Badge({ status, pulse = false }) {
const s = STATUS_STYLES[status] || STATUS_STYLES.closed
const label = LABELS[status] ?? (status ? status.replace(/[_-]/g, ' ') : 'άγνωστο')
return (
<span className={`inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-mono uppercase tracking-[0.08em] ring-1 ring-inset ${s.bg} ${s.text} ${s.ring}`}>
<span className={`relative inline-block h-1.5 w-1.5 rounded-full flex-shrink-0 ${s.dot}`}>
{pulse && (status === 'active' || status === 'open') && (
<span className={`absolute inset-0 rounded-full ${s.dot} animate-ping opacity-75`} />
)}
</span>
{label}
</span>
)
}
+23
View File
@@ -0,0 +1,23 @@
import { BUTTON_VARIANTS, BUTTON_SIZES } from './tokens'
export default function Button({
variant = 'secondary',
size = 'md',
children,
className = '',
...props
}) {
const base = BUTTON_VARIANTS[variant] ?? BUTTON_VARIANTS.secondary
const sizeOverride = BUTTON_SIZES[size]
// Replace the size-specific px/py/text classes from the base with the size override
const cls = size === 'sm'
? base.replace('px-3.5 py-2 text-[13px]', sizeOverride)
: base
return (
<button className={`${cls} ${className}`} {...props}>
{children}
</button>
)
}
+39
View File
@@ -0,0 +1,39 @@
// Card / Panel primitive — wraps the PANEL_CLASS pattern with an optional header slot.
export function Card({ title, subtitle, right, children, padded = true, className = '' }) {
return (
<div className={`overflow-hidden rounded-lg border border-slate-200 bg-white shadow-[0_1px_0_rgba(15,23,42,0.04)] ${className}`}>
{(title || right) && (
<div className="flex items-center justify-between border-b border-slate-100 px-5 py-3">
<div>
{title && <div className="text-[13px] font-semibold text-slate-900">{title}</div>}
{subtitle && <div className="text-[12px] text-slate-500">{subtitle}</div>}
</div>
{right}
</div>
)}
<div className={padded ? 'p-5' : ''}>{children}</div>
</div>
)
}
export function StatCard({ label, value, sub, icon: Icon, accent, size = 'md', className = '' }) {
const sizes = {
sm: { val: 'text-2xl', pad: 'p-4' },
md: { val: 'text-[28px]', pad: 'p-5' },
lg: { val: 'text-4xl', pad: 'p-6' },
}
const s = sizes[size] || sizes.md
return (
<div className={`relative overflow-hidden rounded-lg border border-slate-200 bg-white ${s.pad} shadow-[0_1px_0_rgba(15,23,42,0.04)] ${className}`}>
<div className="flex items-start justify-between">
<div className="text-[11px] font-medium uppercase tracking-[0.1em] text-slate-500">{label}</div>
{Icon && <Icon className="h-4 w-4 text-slate-300" />}
</div>
<div className={`mt-2 font-mono ${s.val} font-medium tabular-nums tracking-tight ${accent ? 'text-sky-600' : 'text-slate-900'}`}>
{value ?? '—'}
</div>
{sub && <div className="mt-1 text-[12px] text-slate-500">{sub}</div>}
</div>
)
}
+64
View File
@@ -0,0 +1,64 @@
import { INPUT_CLASS } from './tokens'
// Text input
export function Input({ className = '', ...props }) {
return (
<div className={`${INPUT_CLASS} ${className}`}>
<input
className="flex-1 bg-transparent outline-none text-[13px] text-slate-700 placeholder-slate-400 min-w-0"
{...props}
/>
</div>
)
}
// Native <select> wrapper
export function Select({ children, className = '', ...props }) {
return (
<div className={`${INPUT_CLASS} ${className}`}>
<select
className="flex-1 bg-transparent outline-none text-[13px] text-slate-700 cursor-pointer min-w-0"
{...props}
>
{children}
</select>
</div>
)
}
// Date input
export function DateInput({ label, icon: Icon, className = '', ...props }) {
return (
<label className={`${INPUT_CLASS} cursor-pointer ${className}`}>
{Icon && <Icon className="h-3.5 w-3.5 text-slate-400 flex-shrink-0" />}
{label && (
<span className="text-[11px] font-medium uppercase tracking-wider text-slate-400 flex-shrink-0">
{label}
</span>
)}
<input
type="date"
className="bg-transparent outline-none text-[13px] text-slate-700 font-normal min-w-0"
{...props}
/>
</label>
)
}
// Labelled text input with optional leading icon
export function LabelledInput({ label, icon: Icon, className = '', ...props }) {
return (
<div className={`${INPUT_CLASS} ${className}`}>
{Icon && <Icon className="h-3.5 w-3.5 text-slate-400 flex-shrink-0" />}
{label && (
<span className="text-[11px] font-medium uppercase tracking-wider text-slate-400 flex-shrink-0">
{label}
</span>
)}
<input
className="flex-1 bg-transparent outline-none text-[13px] text-slate-700 placeholder-slate-400 min-w-0"
{...props}
/>
</div>
)
}
+85
View File
@@ -0,0 +1,85 @@
import { useEffect } from 'react'
import { X } from 'lucide-react'
import Button from './Button'
// General-purpose modal — replaces ConfirmModal and can wrap any content.
//
// Usage (confirm pattern):
// <Modal title="Διαγραφή" onClose={onCancel}>
// <p>Θέλετε σίγουρα να διαγράψετε αυτό το στοιχείο;</p>
// <Modal.Footer>
// <Button variant="secondary" onClick={onCancel}>Ακύρωση</Button>
// <Button variant="danger" onClick={onConfirm}>Διαγραφή</Button>
// </Modal.Footer>
// </Modal>
export default function Modal({ title, onClose, children, maxWidth = 'max-w-sm', className = '' }) {
// Close on Escape
useEffect(() => {
function handler(e) {
if (e.key === 'Escape') onClose?.()
}
document.addEventListener('keydown', handler)
return () => document.removeEventListener('keydown', handler)
}, [onClose])
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
onMouseDown={(e) => { if (e.target === e.currentTarget) onClose?.() }}
>
<div className={`relative w-full ${maxWidth} rounded-xl border border-slate-200 bg-white shadow-xl ${className}`}>
{/* Header */}
{title && (
<div className="flex items-center justify-between border-b border-slate-100 px-5 py-4">
<h2 className="text-[15px] font-semibold text-slate-900">{title}</h2>
{onClose && (
<button
onClick={onClose}
className="rounded-md p-1 text-slate-400 transition hover:bg-slate-100 hover:text-slate-600"
>
<X className="h-4 w-4" />
</button>
)}
</div>
)}
{/* Body */}
<div className="px-5 py-4 space-y-3 text-[13px] text-slate-700">
{children}
</div>
</div>
</div>
)
}
// Footer helper — renders a right-aligned row of action buttons
function ModalFooter({ children }) {
return (
<div className="flex items-center justify-end gap-2 border-t border-slate-100 pt-4 mt-2">
{children}
</div>
)
}
Modal.Footer = ModalFooter
// Convenience: ConfirmModal wrapping Modal for the most common pattern
export function ConfirmModal({
title,
message,
confirmLabel = 'Επιβεβαίωση',
confirmVariant = 'danger',
onConfirm,
onCancel,
}) {
return (
<Modal title={title} onClose={onCancel}>
{message && <p className="text-[13px] text-slate-600">{message}</p>}
<Modal.Footer>
<Button variant="secondary" onClick={onCancel}>Ακύρωση</Button>
<Button variant={confirmVariant} onClick={onConfirm}>{confirmLabel}</Button>
</Modal.Footer>
</Modal>
)
}
+85
View File
@@ -0,0 +1,85 @@
// Unified tab system — identical appearance across every page.
//
// TabGroup → primary nav row (supports lucide icons, used in Reports + Management + Settings)
// TabBar → secondary sub-tab row (pill style, used below TabGroup in Reports)
// TabRow → alias for TabGroup without icons — exact same markup and spacing
// TabCard → white rounded-xl card shell that wraps tab chrome + content
// Use this on any page that has tabs so it sits in the p-6 grey area correctly.
//
// Rule: ALL tab bars use px-6 pt-2 pb-0, border-b border-slate-200, transparent bg (inherits page bg).
// The sky-500 underline indicator is the ONLY active state difference.
const TAB_BTN_BASE =
'relative flex items-center gap-2 px-4 py-3 text-[13.5px] font-medium transition-colors whitespace-nowrap'
const TAB_BTN_ACTIVE = 'text-slate-900'
const TAB_BTN_INACTIVE = 'text-slate-500 hover:text-slate-700'
// ─── Primary tab row (with optional icons) ───────────────────────────────────
export function TabGroup({ tabs, active, onChange }) {
return (
<div className="flex-shrink-0 flex border-b border-slate-200 px-6 pt-2 overflow-x-auto">
{tabs.map((tab) => {
const isActive = tab.id === active
const Icon = tab.icon ?? tab.Icon
return (
<button
key={tab.id}
onClick={() => onChange(tab.id)}
className={`${TAB_BTN_BASE} ${isActive ? TAB_BTN_ACTIVE : TAB_BTN_INACTIVE}`}
>
{Icon && <Icon className={`h-4 w-4 flex-shrink-0 ${isActive ? 'text-sky-500' : 'text-slate-400'}`} />}
{tab.label}
{isActive && <span className="absolute inset-x-2 -bottom-px h-0.5 rounded-full bg-sky-500" />}
</button>
)
})}
</div>
)
}
// ─── Secondary sub-tab row (pill style) ──────────────────────────────────────
export function TabBar({ tabs, active, onChange }) {
return (
<div className="flex-shrink-0 flex items-center gap-1 border-b border-slate-200 px-6 py-2 overflow-x-auto">
{tabs.map((tab) => {
const isActive = tab.id === active
return (
<button
key={tab.id}
onClick={() => onChange(tab.id)}
className={`whitespace-nowrap rounded-md px-3 py-1.5 text-[12px] font-medium transition-colors ${
isActive
? 'bg-sky-100 text-sky-700 font-semibold'
: 'text-slate-500 hover:bg-slate-100 hover:text-slate-700'
}`}
>
{tab.label}
</button>
)
})}
</div>
)
}
// ─── TabRow: identical to TabGroup, kept as named alias ──────────────────────
export function TabRow({ tabs, active, onChange }) {
return <TabGroup tabs={tabs} active={active} onChange={onChange} />
}
// ─── TabCard: the white card shell for any tabbed page ───────────────────────
// Renders a rounded-xl bordered white card that fills the available space.
// Place TabGroup/TabBar as direct children, then a flex-1 overflow content area.
//
// Usage:
// <TabCard>
// <TabGroup ... />
// <TabBar ... /> {/* optional */}
// <div className="flex-1 overflow-y-auto p-6"> ... </div>
// </TabCard>
export function TabCard({ children, className = '' }) {
return (
<div className={`flex flex-col flex-1 min-h-0 rounded-xl border border-slate-200 bg-white shadow-sm overflow-hidden ${className}`}>
{children}
</div>
)
}
+7
View File
@@ -0,0 +1,7 @@
export { default as Button } from './Button'
export { TabGroup, TabBar, TabRow, TabCard } from './Tabs'
export { Card, StatCard } from './Card'
export { default as Badge } from './Badge'
export { Input, Select, DateInput, LabelledInput } from './Input'
export { default as Modal, ConfirmModal } from './Modal'
export * from './tokens'
+143
View File
@@ -0,0 +1,143 @@
// Global design tokens — single source of truth for the manager dashboard UI
// Reports subsystem and all other pages import from here.
export const COLORS = {
// Primary accent
sky500: '#0ea5e9',
sky400: '#38bdf8',
sky600: '#0284c7',
sky50: '#f0f9ff',
// Neutrals
slate900: '#0f172a',
slate800: '#1e293b',
slate700: '#334155',
slate600: '#475569',
slate500: '#64748b',
slate400: '#94a3b8',
slate300: '#cbd5e1',
slate200: '#e2e8f0',
slate100: '#f1f5f9',
slate50: '#f8fafc',
white: '#ffffff',
// Semantic
emerald600: '#059669',
emerald700: '#047857',
emerald50: '#ecfdf5',
emerald200: '#a7f3d0',
rose600: '#e11d48',
rose700: '#be123c',
rose50: '#fff1f2',
rose200: '#fecdd3',
amber500: '#f59e0b',
amber50: '#fffbeb',
amber200: '#fde68a',
violet500: '#8b5cf6',
teal500: '#14b8a6',
}
export const CHART_PALETTE = [
'#60a5fa',
'#7fa67f',
'#dc6a3d',
'#c08aa8',
'#6b8fb5',
'#f59e0b',
'#14b8a6',
'#a78bfa',
]
export const STATUS_STYLES = {
completed: { bg: 'bg-emerald-50', text: 'text-emerald-700', ring: 'ring-emerald-200', dot: 'bg-emerald-500' },
active: { bg: 'bg-sky-50', text: 'text-sky-700', ring: 'ring-sky-200', dot: 'bg-sky-500' },
'force-closed': { bg: 'bg-amber-50', text: 'text-amber-800', ring: 'ring-amber-200', dot: 'bg-amber-500' },
closed: { bg: 'bg-slate-100', text: 'text-slate-600', ring: 'ring-slate-200', dot: 'bg-slate-400' },
paid: { bg: 'bg-emerald-50', text: 'text-emerald-700', ring: 'ring-emerald-200', dot: 'bg-emerald-500' },
open: { bg: 'bg-sky-50', text: 'text-sky-700', ring: 'ring-sky-200', dot: 'bg-sky-500' },
partially_paid: { bg: 'bg-amber-50', text: 'text-amber-800', ring: 'ring-amber-200', dot: 'bg-amber-500' },
cancelled: { bg: 'bg-rose-50', text: 'text-rose-700', ring: 'ring-rose-200', dot: 'bg-rose-500' },
failed: { bg: 'bg-rose-50', text: 'text-rose-700', ring: 'ring-rose-200', dot: 'bg-rose-500' },
success: { bg: 'bg-emerald-50', text: 'text-emerald-700', ring: 'ring-emerald-200', dot: 'bg-emerald-500' },
free: { bg: 'bg-slate-100', text: 'text-slate-600', ring: 'ring-slate-200', dot: 'bg-slate-400' },
}
export const AVATAR_PALETTE = [
'bg-sky-100 text-sky-700',
'bg-emerald-100 text-emerald-700',
'bg-amber-100 text-amber-800',
'bg-violet-100 text-violet-700',
'bg-rose-100 text-rose-700',
'bg-teal-100 text-teal-700',
]
export function avatarColor(id) {
const key = String(id)
let h = 0
for (let i = 0; i < key.length; i++) h = (h * 31 + key.charCodeAt(i)) >>> 0
return AVATAR_PALETTE[h % AVATAR_PALETTE.length]
}
// Formatters
export const fmtEUR = (n) => {
if (n == null) return '—'
return '€' + Number(n).toLocaleString('en-EU', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
}
export const fmtNum = (n) => (n == null ? '—' : Number(n).toLocaleString('en-EU'))
export const fmtTime = (iso) => {
if (!iso) return '—'
return new Date(iso).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' })
}
export const fmtDate = (iso) => {
if (!iso) return '—'
return new Date(iso).toLocaleDateString('en-GB', { weekday: 'short', day: '2-digit', month: 'short' })
}
export const fmtDateTime = (iso) => {
if (!iso) return '—'
return fmtDate(iso) + ' · ' + fmtTime(iso)
}
export const fmtDuration = (startIso, endIso) => {
if (!startIso) return '—'
const start = new Date(startIso)
const end = endIso ? new Date(endIso) : new Date()
const minutes = Math.floor((end - start) / 60000)
if (minutes < 0) return '—'
const h = Math.floor(minutes / 60)
const m = minutes % 60
return `${h}h ${String(m).padStart(2, '0')}m`
}
export const fmtMinutes = (mins) => {
if (mins == null) return '—'
const h = Math.floor(mins / 60)
const m = Math.round(mins % 60)
return h > 0 ? `${h}h ${String(m).padStart(2, '0')}m` : `${m}m`
}
// Common Tailwind class strings
export const PANEL_CLASS = 'overflow-hidden rounded-lg border border-slate-200 bg-white shadow-[0_1px_0_rgba(15,23,42,0.04)]'
export const STAT_CARD_CLASS = 'relative overflow-hidden rounded-lg border border-slate-200 bg-white p-5 shadow-[0_1px_0_rgba(15,23,42,0.04)]'
export const INPUT_CLASS = 'flex items-center gap-2 rounded-md border border-slate-200 bg-white px-2.5 py-1.5 text-[13px] text-slate-700 shadow-[0_1px_0_rgba(15,23,42,0.04)] transition hover:border-slate-300 focus-within:border-sky-400 focus-within:ring-2 focus-within:ring-sky-100'
// Button variant class strings
export const BUTTON_VARIANTS = {
primary: 'inline-flex items-center justify-center gap-2 rounded-md bg-sky-500 px-3.5 py-2 text-[13px] font-medium text-white shadow-[0_1px_0_rgba(15,23,42,0.08)] transition hover:bg-sky-600 active:bg-sky-700 disabled:opacity-50 disabled:pointer-events-none',
secondary: 'inline-flex items-center justify-center gap-2 rounded-md border border-slate-200 bg-white px-3.5 py-2 text-[13px] font-medium text-slate-700 shadow-[0_1px_0_rgba(15,23,42,0.04)] transition hover:bg-slate-50 hover:border-slate-300 active:bg-slate-100 disabled:opacity-50 disabled:pointer-events-none',
ghost: 'inline-flex items-center justify-center gap-2 rounded-md px-3.5 py-2 text-[13px] font-medium text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 active:bg-slate-200 disabled:opacity-50 disabled:pointer-events-none',
danger: 'inline-flex items-center justify-center gap-2 rounded-md bg-rose-500 px-3.5 py-2 text-[13px] font-medium text-white shadow-[0_1px_0_rgba(15,23,42,0.08)] transition hover:bg-rose-600 active:bg-rose-700 disabled:opacity-50 disabled:pointer-events-none',
}
export const BUTTON_SIZES = {
sm: 'px-2.5 py-1.5 text-[12px]',
md: 'px-3.5 py-2 text-[13px]',
}
// Modal overlay
export const MODAL_OVERLAY_CLASS = 'fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4'
// Sidebar nav item
export const NAV_ITEM_BASE = 'flex items-center gap-3 rounded-md px-3 py-2 text-[13px] font-medium transition'
export const NAV_ITEM_ACTIVE = 'bg-sky-50 text-sky-700'
export const NAV_ITEM_INACTIVE = 'text-slate-600 hover:bg-slate-100 hover:text-slate-900'