+
-
-
+
+
{t('profile.language')}
@@ -82,18 +82,18 @@ export default function UserMenuButton({ displayName, onEditProfile, onSignOut }
aria-checked={lng === language}
lang={lng}
onClick={() => chooseLanguage(lng)}
- className="flex w-full items-center gap-2.5 px-3.5 py-2 pl-9 text-[13px] text-slate-700 hover:bg-slate-50 transition-colors"
+ className="flex w-full items-center gap-2.5 px-3.5 py-2 pl-9 text-[13px] text-ink hover:bg-surface-2 transition-colors"
>
{LANGUAGE_NAMES[lng]}
- {lng === language &&
}
+ {lng === language &&
}
))}
-
+
- {tab === 'list' ?
:
}
+ {tab === 'list' ?
:
}
)
diff --git a/manager_dashboard/src/pages/SetupWizard.jsx b/manager_dashboard/src/pages/SetupWizard.jsx
deleted file mode 100644
index 5b721ef..0000000
--- a/manager_dashboard/src/pages/SetupWizard.jsx
+++ /dev/null
@@ -1,542 +0,0 @@
-import { useState, useEffect, useRef } from 'react'
-import { LANGUAGE_NAMES, useTranslation } from '@xenia/i18n'
-import { browserTimeZone, timeZones } from './Settings/sections/timeZones'
-import { useNavigate } from 'react-router-dom'
-import {
- ArrowRight, User, Mail, Lock, Building2, Coffee,
- UtensilsCrossed, Beer, ShoppingBag, CheckCircle2, ChevronRight, Hash,
-} from 'lucide-react'
-import client from '../api/client'
-import Button from '../ui/Button'
-import { LabelledInput } from '../ui/Input'
-
-// ─── Step indicator ───────────────────────────────────────────────────────────
-
-function StepDots({ total, current }) {
- return (
-
- {Array.from({ length: total }).map((_, i) => (
-
- ))}
-
- )
-}
-
-// ─── Venue type selector (multi-select) ───────────────────────────────────────
-
-const VENUE_TYPES = [
- { id: 'restaurant', label: 'Restaurant', Icon: UtensilsCrossed },
- { id: 'bar', label: 'Bar', Icon: Beer },
- { id: 'coffee_shop', label: 'Coffee Shop', Icon: Coffee },
- { id: 'fast_food', label: 'Fast Food', Icon: ShoppingBag },
-]
-
-function VenueTypeButton({ type, selected, onToggle }) {
- const { label, Icon } = type
- return (
-
onToggle(type.id)}
- className={`relative flex flex-col items-center gap-2 rounded-xl border-2 p-4 text-[13px] font-medium transition-all ${
- selected
- ? 'border-sky-500 bg-sky-50 text-sky-700'
- : 'border-slate-200 bg-white text-slate-600 hover:border-slate-300 hover:bg-slate-50'
- }`}
- >
- {selected && (
-
-
-
- )}
-
- {label}
-
- )
-}
-
-// ─── PIN pad ──────────────────────────────────────────────────────────────────
-
-const PIN_DIGITS = ['1','2','3','4','5','6','7','8','9','','0','⌫']
-
-function PinPad({ pin, onChange }) {
- function press(d) {
- if (d === '⌫') { onChange(p => p.slice(0, -1)); return }
- if (d === '') return
- if (pin.length >= 6) return
- onChange(p => p + d)
- }
- return (
-
-
- {Array.from({ length: 4 }).map((_, i) => (
-
- ))}
-
-
- {PIN_DIGITS.map((d, i) => (
- press(d)}
- disabled={d === ''}
- className={`h-12 rounded-xl text-lg font-semibold transition-colors ${
- d === ''
- ? 'invisible'
- : d === '⌫'
- ? 'bg-slate-100 hover:bg-slate-200 text-slate-600'
- : 'bg-slate-100 hover:bg-sky-100 active:bg-sky-200 text-slate-800'
- }`}
- >
- {d}
-
- ))}
-
-
- )
-}
-
-// ─── Steps ───────────────────────────────────────────────────────────────────
-
-function StepWelcome({ onNext }) {
- return (
-
-
-
-
-
-
-
Welcome to Xenia POS
-
- The complete point-of-sale system for your venue. Let's get you set up
- in just a few steps — it won't take long.
-
-
-
-
- {[
- 'Create your manager account',
- 'Tell us about your venue',
- 'You\'re ready to go',
- ].map((s, i) => (
-
- ))}
-
-
-
- Get Started
-
-
-
Thank you for choosing Xenia POS.
-
- )
-}
-
-function StepAccount({ data, onChange, onNext, onBack }) {
- const [errors, setErrors] = useState({})
- // Live password match: debounce 1s after confirm changes
- const confirmTimer = useRef(null)
-
- function handleConfirmChange(value) {
- onChange('confirm', value)
- clearTimeout(confirmTimer.current)
- confirmTimer.current = setTimeout(() => {
- if (value && data.password && value !== data.password) {
- setErrors(e => ({ ...e, confirm: 'Passwords do not match' }))
- } else {
- setErrors(e => { const next = { ...e }; delete next.confirm; return next })
- }
- }, 1000)
- }
-
- // Also clear the error immediately if they now match
- function handlePasswordChange(value) {
- onChange('password', value)
- if (data.confirm && value === data.confirm) {
- setErrors(e => { const next = { ...e }; delete next.confirm; return next })
- }
- }
-
- function validate() {
- const e = {}
- if (!data.username.trim()) e.username = 'Username is required'
- if (!data.fullName.trim()) e.fullName = 'Full name is required'
- if (!data.email.trim()) e.email = 'Email is required'
- else if (!/\S+@\S+\.\S+/.test(data.email)) e.email = 'Enter a valid email'
- if (data.password.length < 6) e.password = 'At least 6 characters'
- if (data.password !== data.confirm) e.confirm = 'Passwords do not match'
- setErrors(e)
- return Object.keys(e).length === 0
- }
-
- return (
-
-
-
Create your manager account
-
This will be the primary administrator account.
-
-
-
-
-
onChange('username', e.target.value)}
- autoComplete="off"
- autoFocus
- />
- {errors.username && {errors.username}
}
-
-
-
-
onChange('fullName', e.target.value)}
- autoComplete="off"
- />
- {errors.fullName && {errors.fullName}
}
-
-
-
-
onChange('email', e.target.value)}
- type="email"
- autoComplete="off"
- />
- {errors.email && {errors.email}
}
-
-
-
-
handlePasswordChange(e.target.value)}
- type="password"
- autoComplete="new-password"
- />
- {errors.password && {errors.password}
}
-
-
-
-
handleConfirmChange(e.target.value)}
- type="password"
- autoComplete="new-password"
- />
- {errors.confirm && {errors.confirm}
}
-
-
-
-
-
- Back
-
- { if (validate()) onNext() }}>
- Continue
-
-
-
- )
-}
-
-function StepVenue({ data, onChange, onNext, onBack }) {
- const { t } = useTranslation('manager')
- const [errors, setErrors] = useState({})
-
- function toggleType(id) {
- const current = data.venueTypes
- const next = current.includes(id)
- ? current.filter(v => v !== id)
- : [...current, id]
- onChange('venueTypes', next)
- }
-
- function validate() {
- const e = {}
- if (data.venueTypes.length === 0) e.venueType = 'Please select at least one type'
- if (!data.venueName.trim()) e.venueName = 'Venue name is required'
- setErrors(e)
- return Object.keys(e).length === 0
- }
-
- return (
-
-
-
Tell us about your venue
-
Select all that apply — you can always change this later.
-
-
-
-
-
Venue type
-
- {VENUE_TYPES.map(type => (
-
- ))}
-
- {errors.venueType &&
{errors.venueType}
}
-
-
-
-
-
-
- {t('setup.languageHint')}
-
-
-
-
-
Venue name
-
onChange('venueName', e.target.value)}
- autoComplete="off"
- />
- {errors.venueName && {errors.venueName}
}
-
-
-
-
-
- Back
-
- { if (validate()) onNext() }}>
- Continue
-
-
-
- )
-}
-
-function StepPin({ pin, onChange, onNext, onBack }) {
- const hasPin = pin.length >= 4
-
- return (
-
-
-
Set a quick-access PIN
-
- Optional. Used to unlock the dashboard quickly when it's locked,
- without typing your full password.
-
-
-
-
-
- {hasPin && (
-
- PIN set — {pin.length} digits
-
- )}
-
-
-
- Back
-
-
- {hasPin ? <>Continue > : 'Skip for now'}
-
-
-
- )
-}
-
-function StepDone({ onGoToLogin, loading, error }) {
- return (
-
-
-
-
-
-
-
You're all set!
-
- Your manager account is ready. Log in and start configuring your
- products, tables, and staff.
-
-
-
-
- {['Add your menu and products', 'Set up tables and zones', 'Add your waiters'].map((tip, i) => (
-
-
- {tip}
-
- ))}
-
-
- {error &&
{error}
}
-
-
- {loading ? 'Setting up…' : 'Go to Login'}
- {!loading && }
-
-
- )
-}
-
-// ─── Main wizard ──────────────────────────────────────────────────────────────
-
-// Steps: 0=welcome, 1=account, 2=venue, 3=pin, 4=done
-const INNER_STEPS = 3 // steps 1-3 show the dot indicator
-
-export default function SetupWizard() {
- const navigate = useNavigate()
- const [step, setStep] = useState(0)
- const [loading, setLoading] = useState(false)
- const [error, setError] = useState('')
-
- const [account, setAccount] = useState({
- username: '', fullName: '', email: '', password: '', confirm: '',
- })
- // Staff language and time zone (2.6f): v2 defaults to English, so ask; start from the browser's
- const [venue, setVenue] = useState(() => ({
- venueTypes: [], venueName: '',
- language: (typeof navigator !== 'undefined' && navigator.language?.toLowerCase().startsWith('el')) ? 'el' : 'en',
- timezone: browserTimeZone(),
- }))
- const [pin, setPin] = useState('')
-
- function updateAccount(key, value) {
- setAccount(prev => ({ ...prev, [key]: value }))
- }
- function updateVenue(key, value) {
- setVenue(prev => ({ ...prev, [key]: value }))
- }
-
- async function handleFinish() {
- setLoading(true)
- setError('')
- try {
- await client.post('/api/setup/init', {
- username: account.username.trim(),
- password: account.password,
- email: account.email.trim(),
- full_name: account.fullName.trim(),
- venue_type: venue.venueTypes.join(','),
- venue_name: venue.venueName.trim(),
- language: venue.language,
- timezone: venue.timezone,
- pin: pin.length >= 4 ? pin : undefined,
- })
- navigate('/login', { replace: true })
- } catch (err) {
- setError(err.response?.data?.detail || 'Something went wrong. Please try again.')
- setLoading(false)
- }
- }
-
- return (
-
-
-
- {/* Dot indicator for inner steps only */}
- {step >= 1 && step <= INNER_STEPS && (
-
-
-
- )}
-
- {step === 0 &&
setStep(1)} />}
-
- {step === 1 && (
- setStep(2)}
- onBack={() => setStep(0)}
- />
- )}
-
- {step === 2 && (
- setStep(3)}
- onBack={() => setStep(1)}
- />
- )}
-
- {step === 3 && (
- setStep(4)}
- onBack={() => setStep(2)}
- />
- )}
-
- {step === 4 && (
-
- )}
-
-
-
- Xenia POS · First-time Setup
-
-
-
- )
-}
diff --git a/manager_dashboard/src/pages/TablesConfigTab.jsx b/manager_dashboard/src/pages/TablesConfigTab.jsx
deleted file mode 100644
index 401c554..0000000
--- a/manager_dashboard/src/pages/TablesConfigTab.jsx
+++ /dev/null
@@ -1,825 +0,0 @@
-import { useState, useRef } from 'react'
-import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
-import toast from 'react-hot-toast'
-import client from '../api/client'
-import { ConfirmModal } from '../ui/Modal'
-import Button from '../ui/Button'
-
-const MAX_TABLE_NAME_LENGTH = 6
-
-const ZONE_COLORS = ['#6366f1','#0ea5e9','#10b981','#f59e0b','#ef4444','#ec4899','#8b5cf6','#14b8a6','#f97316','#64748b']
-
-function ZoneColorPicker({ value, onChange }) {
- return (
-
- onChange(null)}
- className="w-7 h-7 rounded-full border-2 bg-gray-200 transition-all"
- style={{ borderColor: !value ? '#000' : 'transparent' }}
- title="Χωρίς χρώμα"
- />
- {ZONE_COLORS.map(c => (
- onChange(c)}
- className="w-7 h-7 rounded-full border-2 transition-all"
- style={{ background: c, borderColor: value === c ? '#000' : 'transparent' }}
- />
- ))}
-
- )
-}
-
-export default function TablesPage() {
- const qc = useQueryClient()
- const [addModal, setAddModal] = useState(false)
- const [editModal, setEditModal] = useState(null)
- const [batchModal, setBatchModal] = useState(null) // group object or null
- const [groupModal, setGroupModal] = useState(null) // null | {} | group object
- const [confirmDelete, setConfirmDelete] = useState(null)
- const [bulkMoveModal, setBulkMoveModal] = useState(false)
- const [bulkRenameModal, setBulkRenameModal] = useState(false)
- const [showInactive, setShowInactive] = useState(false)
- const [selectMode, setSelectMode] = useState(false)
- const [activeTab, setActiveTab] = useState('all') // 'all' | group.id
- const [selected, setSelected] = useState(new Set())
- const [anyHovered, setAnyHovered] = useState(false)
- const dragGroupId = useRef(null)
- const [dragOverGap, setDragOverGap] = useState(null) // index into groups array (0 = before first)
-
- const { data: tables = [], isLoading } = useQuery({
- queryKey: ['tables-all', showInactive],
- queryFn: () => client.get(`/api/tables/?include_inactive=${showInactive}`).then(r => r.data),
- })
-
- const { data: groups = [] } = useQuery({
- queryKey: ['table-groups'],
- queryFn: () => client.get('/api/tables/groups').then(r => r.data),
- })
-
- const invalidate = () => {
- qc.invalidateQueries({ queryKey: ['tables-all'] })
- qc.invalidateQueries({ queryKey: ['tables'] })
- }
- const invalidateGroups = () => qc.invalidateQueries({ queryKey: ['table-groups'] })
-
- const createTable = useMutation({
- mutationFn: (body) => client.post('/api/tables/', body),
- onSuccess: () => { toast.success('Τραπέζι δημιουργήθηκε'); setAddModal(false); invalidate() },
- onError: (err) => toast.error(err.response?.data?.detail || 'Σφάλμα'),
- })
-
- const batchCreate = useMutation({
- mutationFn: (body) => client.post('/api/tables/batch', body),
- onSuccess: (res) => { toast.success(`${res.data.length} τραπέζια δημιουργήθηκαν`); setBatchModal(null); invalidate() },
- onError: (err) => toast.error(err.response?.data?.detail || 'Σφάλμα'),
- })
-
- const updateTable = useMutation({
- mutationFn: ({ id, ...body }) => client.put(`/api/tables/${id}`, body),
- onSuccess: () => { toast.success('Αποθηκεύτηκε'); setEditModal(null); invalidate() },
- onError: () => toast.error('Σφάλμα'),
- })
-
- const deleteTable = useMutation({
- mutationFn: ({ id, hard }) => client.delete(`/api/tables/${id}?hard=${hard}`),
- onSuccess: (_, vars) => {
- toast.success(vars.hard ? 'Διαγράφηκε' : 'Απενεργοποιήθηκε')
- setConfirmDelete(null)
- invalidate()
- },
- onError: (err) => toast.error(err.response?.data?.detail || 'Σφάλμα'),
- })
-
- const saveGroup = useMutation({
- mutationFn: (body) => groupModal?.id
- ? client.put(`/api/tables/groups/${groupModal.id}`, body)
- : client.post('/api/tables/groups', body),
- onSuccess: () => { toast.success('Ζώνη αποθηκεύτηκε'); setGroupModal(null); invalidateGroups(); invalidate() },
- onError: (err) => toast.error(err.response?.data?.detail || 'Σφάλμα'),
- })
-
- const deleteGroup = useMutation({
- mutationFn: (id) => client.delete(`/api/tables/groups/${id}`),
- onSuccess: () => { toast.success('Ζώνη διαγράφηκε'); setGroupModal(null); invalidateGroups(); invalidate() },
- onError: () => toast.error('Σφάλμα'),
- })
-
- const reorderGroups = useMutation({
- mutationFn: (ids) => client.put('/api/tables/groups/reorder', ids),
- onSuccess: invalidateGroups,
- onError: () => toast.error('Σφάλμα αναδιάταξης'),
- })
-
- // Filter tables for the active tab
- const visibleTables = activeTab === 'all'
- ? tables
- : activeTab === 'ungrouped'
- ? tables.filter(t => !t.group_id)
- : tables.filter(t => t.group_id === activeTab)
-
- const toggleSelect = (id) => setSelected(prev => {
- const n = new Set(prev); n.has(id) ? n.delete(id) : n.add(id); return n
- })
- const clearSelect = () => setSelected(new Set())
- const anySelected = selected.size > 0
- const allVisibleSelected = visibleTables.length > 0 && visibleTables.every(t => selected.has(t.id))
-
- function toggleSelectAll() {
- if (allVisibleSelected) {
- // Deselect all visible
- setSelected(prev => {
- const n = new Set(prev)
- visibleTables.forEach(t => n.delete(t.id))
- return n
- })
- } else {
- // Select all visible
- setSelected(prev => {
- const n = new Set(prev)
- visibleTables.forEach(t => n.add(t.id))
- return n
- })
- }
- }
-
- function exitSelectMode() {
- setSelectMode(false)
- clearSelect()
- }
-
- function bulkDelete() {
- setConfirmDelete({ type: 'bulk', ids: [...selected] })
- }
-
- async function handleBulkMove(groupId) {
- const ids = [...selected]
- await Promise.allSettled(ids.map(id => client.put(`/api/tables/${id}`, { group_id: groupId })))
- toast.success(`${ids.length} τραπέζια μετακινήθηκαν`)
- setBulkMoveModal(false)
- exitSelectMode()
- invalidate()
- }
-
- async function handleBulkRename(prefix, startNumber) {
- const ids = [...selected]
- // Apply names in the order tables appear in the visible list
- const orderedIds = visibleTables.filter(t => selected.has(t.id)).map(t => t.id)
- const patches = orderedIds.map((id, i) => ({
- id,
- label: `${prefix}${startNumber + i}`,
- }))
- await Promise.allSettled(patches.map(({ id, label }) => client.put(`/api/tables/${id}`, { label })))
- toast.success(`${orderedIds.length} τραπέζια μετονομάστηκαν`)
- setBulkRenameModal(false)
- exitSelectMode()
- invalidate()
- }
-
- if (isLoading) return
Φόρτωση…
-
- const zoneTabs = [
- { id: 'all', label: 'Όλα', color: null },
- ...groups.map(g => ({ id: g.id, label: g.prefix ? `${g.prefix} – ${g.name}` : g.name, color: g.color, group: g })),
- ...(tables.some(t => !t.group_id) ? [{ id: 'ungrouped', label: 'Χωρίς ζώνη', color: null }] : []),
- ]
-
- const totalTables = tables.length
- const inactiveTables = tables.filter(t => !t.is_active).length
- const zoneCount = groups.length
-
- return (
-
- {/* Toolbar */}
-
- {/* Stats — left side */}
- {!isLoading && !anySelected && !selectMode && (
-
- {totalTables} τραπέζια
- ·
- {zoneCount} {zoneCount === 1 ? 'ζώνη' : 'ζώνες'}
- {inactiveTables > 0 && (
- <>
- ·
- {inactiveTables} ανενεργά
- >
- )}
-
- )}
-
- {/* Multi-select action bar */}
- {(selectMode || anySelected) && (
- <>
- {/* Select-all / deselect-all toggle + close */}
-
- ✕
- {anySelected ? `${selected.size} επιλεγμένα` : 'Επιλογή'}
-
-
- {allVisibleSelected ? 'Αποεπιλογή όλων' : 'Επιλογή όλων'}
-
- {anySelected && (
- <>
-
-
setBulkMoveModal(true)}>
- Μετακίνηση ζώνης
-
-
setBulkRenameModal(true)}>
- Μαζική μετονομασία
-
-
- Διαγραφή
-
- >
- )}
-
- >
- )}
-
- {!selectMode && !anySelected &&
}
-
-
setShowInactive(v => !v)}
- >
- {showInactive ? '✓ ' : ''}Ανενεργά
-
- {!selectMode && (
-
setSelectMode(true)}>
- Επιλογή
-
- )}
-
setGroupModal({})}>+ Νέα ζώνη
-
setAddModal(true)}>+ Νέο τραπέζι
-
-
- {/* Zone tabs */}
-
- {zoneTabs.map(tab => {
- const isGroup = tab.id !== 'all' && tab.id !== 'ungrouped'
- const groupIdx = isGroup ? groups.findIndex(g => g.id === tab.id) : -1
-
- function handleDragOver(e) {
- e.preventDefault()
- // Use mouse position within the tab to decide left-half vs right-half gap
- const rect = e.currentTarget.getBoundingClientRect()
- const isLeftHalf = e.clientX < rect.left + rect.width / 2
- setDragOverGap(isLeftHalf ? groupIdx : groupIdx + 1)
- }
-
- function handleDrop(e) {
- e.preventDefault()
- const fromId = dragGroupId.current
- dragGroupId.current = null
- setDragOverGap(null)
- if (!fromId) return
- const groupIds = groups.map(g => g.id)
- const fromIdx = groupIds.indexOf(fromId)
- if (fromIdx === -1 || dragOverGap === null) return
- const reordered = [...groupIds]
- reordered.splice(fromIdx, 1)
- // After removing the dragged item, adjust target index
- const insertAt = dragOverGap > fromIdx ? dragOverGap - 1 : dragOverGap
- reordered.splice(insertAt, 0, fromId)
- if (reordered.join() !== groupIds.join()) reorderGroups.mutate(reordered)
- }
-
- const showLineLeft = isGroup && dragOverGap === groupIdx
- const showLineRight = isGroup && dragOverGap === groupIdx + 1 && groupIdx === groups.length - 1
-
- return (
-
- {/* Drop indicator line — left side of this tab */}
- {showLineLeft && (
-
- )}
-
-
{ setActiveTab(tab.id); clearSelect() }}
- draggable={isGroup}
- onDragStart={isGroup ? () => { dragGroupId.current = tab.id } : undefined}
- onDragOver={isGroup ? handleDragOver : undefined}
- onDragLeave={isGroup ? () => setDragOverGap(null) : undefined}
- onDrop={isGroup ? handleDrop : undefined}
- onDragEnd={isGroup ? () => { dragGroupId.current = null; setDragOverGap(null) } : undefined}
- className={`flex items-center gap-1.5 px-4 py-2.5 text-sm font-medium transition-colors border-b-2 -mb-px ${
- activeTab === tab.id
- ? 'border-sky-500 text-sky-600'
- : 'border-transparent text-slate-500 hover:text-slate-700 hover:border-slate-300'
- } ${isGroup ? 'cursor-grab active:cursor-grabbing' : ''}`}
- >
- {isGroup && ⠿}
- {tab.color && }
- {tab.label}
-
- ({tab.id === 'all' ? tables.length : tab.id === 'ungrouped' ? tables.filter(t => !t.group_id).length : tables.filter(t => t.group_id === tab.id).length})
-
-
-
- {/* Drop indicator line — right side of the last group tab */}
- {showLineRight && (
-
- )}
-
- )
- })}
-
-
- {/* Zone action bar (when viewing a specific zone) */}
- {activeTab !== 'all' && activeTab !== 'ungrouped' && (() => {
- const g = groups.find(g => g.id === activeTab)
- if (!g) return null
- return (
-
- {g.name}
- {g.prefix && {g.prefix}}
- setGroupModal(g)} className="text-xs text-slate-400 hover:text-slate-600 underline ml-1">Επεξεργασία
- setBatchModal(g)} className="ml-auto">+ Μαζική προσθήκη
-
- )
- })()}
-
- {/* Tables list */}
-
- {visibleTables.length === 0 ? (
-
- {showInactive ? 'Δεν υπάρχουν τραπέζια.' : 'Δεν υπάρχουν ενεργά τραπέζια.'}
-
- ) : (() => {
- // Build a set of labels that appear more than once across ALL tables (not just visible)
- const labelCounts = {}
- tables.forEach(t => { if (t.label) labelCounts[t.label] = (labelCounts[t.label] || 0) + 1 })
- const duplicateLabels = new Set(Object.keys(labelCounts).filter(l => labelCounts[l] > 1))
-
- return (
-
- {visibleTables.map((t, idx) => {
- const isSelected = selected.has(t.id)
- const isDuplicate = t.label && duplicateLabels.has(t.label)
- const showCheckbox = selectMode || anySelected || isSelected
- return (
-
toggleSelect(t.id) : undefined}
- onMouseEnter={() => setAnyHovered(true)}
- onMouseLeave={() => setAnyHovered(false)}
- >
- {/* Number / Checkbox */}
-
- {showCheckbox ? (
- toggleSelect(t.id)}
- className="w-4 h-4 rounded accent-sky-500 cursor-pointer"
- onClick={e => e.stopPropagation()}
- />
- ) : (
- {idx + 1}
- )}
- {!showCheckbox && (
- { setSelectMode(true); toggleSelect(t.id) }}
- className="hidden group-hover:block w-4 h-4 rounded accent-sky-500 cursor-pointer"
- onClick={e => e.stopPropagation()}
- />
- )}
-
-
-
{t.label || `Τραπέζι ${t.number}`}
- {isDuplicate && (
-
- Διπλό όνομα
-
- )}
- {t.seat_count != null && (
-
- {t.seat_count} θέσ.
-
- )}
- {t.group && (
-
- {t.group.name}
-
- )}
- {!t.is_active &&
Ανενεργό}
- {!selectMode && (
- <>
-
setEditModal(t)}>Επεξεργασία
- {t.is_active
- ?
!t.has_active_order && setConfirmDelete({ type: 'single', id: t.id, hard: false })}
- disabled={t.has_active_order}
- title={t.has_active_order ? 'Υπάρχει ενεργή παραγγελία' : undefined}
- className="text-amber-600 hover:bg-amber-50 disabled:opacity-40 disabled:cursor-not-allowed"
- >Απενεργ.
- :
updateTable.mutate({ id: t.id, is_active: true })}
- className="text-green-600 hover:bg-green-50"
- >Ενεργοπ.
- }
-
!t.has_active_order && setConfirmDelete({ type: 'single', id: t.id, hard: true })}
- disabled={t.has_active_order}
- title={t.has_active_order ? 'Υπάρχει ενεργή παραγγελία' : undefined}
- className="disabled:opacity-40 disabled:cursor-not-allowed"
- >Διαγραφή
- >
- )}
-
- )
- })}
-
- )
- })()}
-
-
- {/* Add single table */}
- {addModal && (
-
createTable.mutate({ label: f.label || null, group_id: f.group_id ? Number(f.group_id) : null, seat_count: f.seat_count || null })}
- onClose={() => setAddModal(false)}
- />
- )}
-
- {/* Edit table */}
- {editModal && (
- updateTable.mutate({ id: editModal.id, label: f.label || null, group_id: f.group_id ? Number(f.group_id) : null, seat_count: f.seat_count || null })}
- onClose={() => setEditModal(null)}
- />
- )}
-
- {/* Batch add */}
- {batchModal !== null && (
- batchCreate.mutate(body)}
- onClose={() => setBatchModal(null)}
- />
- )}
-
- {/* Bulk move zone */}
- {bulkMoveModal && (
- setBulkMoveModal(false)}
- />
- )}
-
- {/* Bulk rename */}
- {bulkRenameModal && (
- selected.has(t.id))}
- onSave={handleBulkRename}
- onClose={() => setBulkRenameModal(false)}
- />
- )}
-
- {/* Group/Zone form */}
- {groupModal !== null && (
- saveGroup.mutate(data)}
- onDelete={groupModal.id ? () => deleteGroup.mutate(groupModal.id) : null}
- onClose={() => setGroupModal(null)}
- />
- )}
-
- {/* Delete confirmation */}
- {confirmDelete && (
- {
- if (confirmDelete.type === 'bulk') {
- await Promise.allSettled(confirmDelete.ids.map(id => client.delete(`/api/tables/${id}?hard=true`)))
- toast.success(`${confirmDelete.ids.length} τραπέζια διαγράφηκαν`)
- setConfirmDelete(null); exitSelectMode(); invalidate()
- } else {
- deleteTable.mutate({ id: confirmDelete.id, hard: confirmDelete.hard })
- }
- }}
- onCancel={() => setConfirmDelete(null)}
- />
- )}
-
- )
-}
-
-function TableModal({ title, initial, groups, onSave, onClose }) {
- const [form, setForm] = useState(initial)
- const labelLen = (form.label || '').length
- const labelTooLong = labelLen > MAX_TABLE_NAME_LENGTH
-
- return (
-
-
-
{title}
-
-
-
setForm(f => ({ ...f, label: e.target.value }))}
- autoFocus
- />
-
-
Αφήστε κενό για αυτόματη αρίθμηση.
- {form.label ? (
-
= MAX_TABLE_NAME_LENGTH ? 'text-red-500' : 'text-gray-400'}`}>
- {labelLen}/{MAX_TABLE_NAME_LENGTH}
-
- ) : null}
-
- {labelTooLong && (
-
Το όνομα δεν μπορεί να υπερβαίνει τους {MAX_TABLE_NAME_LENGTH} χαρακτήρες.
- )}
-
-
-
-
-
-
-
-
setForm(f => ({ ...f, seat_count: e.target.value ? Number(e.target.value) : null }))}
- />
-
Αφήστε κενό αν δεν θέλετε να ορίσετε θέσεις.
-
-
- Ακύρωση
- onSave(form)}
- disabled={labelTooLong}
- className="flex-1 btn btn-primary disabled:opacity-40 disabled:cursor-not-allowed"
- >
- Αποθήκευση
-
-
-
-
- )
-}
-
-function BulkMoveModal({ count, groups, onSave, onClose }) {
- const [groupId, setGroupId] = useState('')
-
- return (
-
-
-
Μετακίνηση σε ζώνη
-
{count} {count === 1 ? 'τραπέζι' : 'τραπέζια'} επιλεγμένα.
-
-
-
-
-
- Ακύρωση
- onSave(groupId ? Number(groupId) : null)}
- className="flex-1 btn btn-primary"
- >
- Μετακίνηση
-
-
-
-
- )
-}
-
-function BulkRenameModal({ selectedTables, onSave, onClose }) {
- const count = selectedTables.length
- const [prefix, setPrefix] = useState('')
- const [startNumber, setStartNumber] = useState(1)
-
- const trimmedPrefix = prefix.trim()
- const lastN = startNumber + count - 1
- const worstCase = `${trimmedPrefix}${lastN}`
- const lengthError = trimmedPrefix && worstCase.length > MAX_TABLE_NAME_LENGTH
- ? `Το τελευταίο όνομα θα είναι '${worstCase}' (${worstCase.length} χαρ.). Μικρύνετε το πρόθεμα ή αλλάξτε αριθμό εκκίνησης.`
- : null
-
- // Live preview — at most 5 names shown
- const previewNames = Array.from({ length: Math.min(count, 5) }, (_, i) =>
- trimmedPrefix ? `${trimmedPrefix}${startNumber + i}` : null
- )
- const hasMore = count > 5
-
- return (
-
-
-
Μαζική μετονομασία
-
- {count} {count === 1 ? 'τραπέζι' : 'τραπέζια'} επιλεγμένα — θα μετονομαστούν με τη σειρά που εμφανίζονται στη λίστα.
-
-
-
-
- setPrefix(e.target.value)}
- autoFocus
- />
-
-
-
-
- setStartNumber(Math.max(1, Number(e.target.value) || 1))}
- />
-
-
- {/* Live preview */}
- {trimmedPrefix && !lengthError && (
-
-
Προεπισκόπηση:
-
- {previewNames.map((name, i) => (
-
- {name}
-
- ))}
- {hasMore && (
- … +{count - 5} ακόμα
- )}
-
-
- )}
-
- {lengthError && (
-
{lengthError}
- )}
-
-
- Ακύρωση
- onSave(trimmedPrefix, startNumber)}
- disabled={!trimmedPrefix || !!lengthError}
- className="flex-1 btn btn-primary disabled:opacity-40 disabled:cursor-not-allowed"
- >
- Μετονομασία {count} τραπεζιών
-
-
-
-
- )
-}
-
-function computeStartNumber(tables, groupId, prefix) {
- if (!prefix) return 1
- const inGroup = groupId ? tables.filter(t => t.group_id === groupId) : []
- const used = inGroup
- .filter(t => t.label && t.label.startsWith(prefix))
- .map(t => {
- const suffix = t.label.slice(prefix.length)
- return /^\d+$/.test(suffix) ? parseInt(suffix, 10) : null
- })
- .filter(n => n !== null)
- return used.length > 0 ? Math.max(...used) + 1 : 1
-}
-
-function BatchModal({ group, tables, onSave, onClose }) {
- const [count, setCount] = useState(5)
- const [prefix, setPrefix] = useState(group?.prefix ? `${group.prefix}-` : '')
-
- const trimmedPrefix = prefix.trim()
- const startNumber = computeStartNumber(tables, group?.id ?? null, trimmedPrefix)
- const lastN = startNumber + count - 1
- const worstCase = `${trimmedPrefix}${lastN}`
- const lengthError = trimmedPrefix && worstCase.length > MAX_TABLE_NAME_LENGTH
- ? `O τελευταίος πίνακας θα ονομαστεί '${worstCase}' (${worstCase.length} χαρ.). Μικρύνετε το πρόθεμα ή μειώστε τον αριθμό.`
- : null
-
- return (
-
-
-
Μαζική προσθήκη τραπεζιών
- {group &&
Ζώνη: {group.name}
}
-
-
-
setPrefix(e.target.value)}
- autoFocus
- />
- {lengthError ? (
-
{lengthError}
- ) : (
-
Τα ονόματα θα αριθμηθούν αυτόματα συνεχίζοντας από εκεί που σταμάτησαν.
- )}
-
-
-
- setCount(Number(e.target.value))} />
-
-
- Ακύρωση
- onSave({ group_id: group?.id ?? null, count, name_prefix: trimmedPrefix })}
- disabled={count < 1 || !trimmedPrefix || !!lengthError}
- className="flex-1 btn btn-primary disabled:opacity-40 disabled:cursor-not-allowed"
- >
- Δημιουργία {count > 0 && trimmedPrefix && !lengthError ? `(${trimmedPrefix}${startNumber} … ${trimmedPrefix}${lastN})` : ''}
-
-
-
-
- )
-}
-
-function GroupModal({ group, onSave, onDelete, onClose }) {
- const [name, setName] = useState(group.name || '')
- const [prefix, setPrefix] = useState(group.prefix || '')
- const [color, setColor] = useState(group.color || null)
- return (
-
-
-
{group.id ? 'Επεξεργασία ζώνης' : 'Νέα ζώνη'}
-
-
- setName(e.target.value)} autoFocus placeholder="π.χ. Beachside" />
-
-
-
-
setPrefix(e.target.value)} placeholder="π.χ. BS" />
-
Χρησιμοποιείται ως προτεινόμενο πρόθεμα στη μαζική προσθήκη.
-
-
-
-
-
-
- {onDelete && Διαγραφή}
- Ακύρωση
- onSave({ name, prefix: prefix || null, color: color || null })} disabled={!name.trim()} className="flex-1 btn btn-primary">Αποθήκευση
-
-
-
- )
-}
diff --git a/manager_dashboard/src/pages/overview/OverviewPage.jsx b/manager_dashboard/src/pages/overview/OverviewPage.jsx
index 933bf86..268b44a 100644
--- a/manager_dashboard/src/pages/overview/OverviewPage.jsx
+++ b/manager_dashboard/src/pages/overview/OverviewPage.jsx
@@ -15,7 +15,7 @@ import { useCan, useModule } from '@xenia/access'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, IconButton, Spinner, cx } from '@xenia/ui'
import client from '../../api/client'
-import { LicenseContext } from '../../layouts/AppLayout'
+import { LicenseContext } from '../../shell/licenseContext'
import { useLiveQuery } from '../../live/useLiveQuery'
import BookingsCard, { BookingDialog } from './BookingsCard'
import DaySummaryDialog from './DaySummaryDialog'
diff --git a/manager_dashboard/src/pages/setup/SetupWizard.jsx b/manager_dashboard/src/pages/setup/SetupWizard.jsx
new file mode 100644
index 0000000..e1fef20
--- /dev/null
+++ b/manager_dashboard/src/pages/setup/SetupWizard.jsx
@@ -0,0 +1,189 @@
+// First-run setup (plan step 6.14b; was the v1 SetupWizard): on a fresh install (no manager yet)
+// the sign-in page sends here. Welcome → the owner's account (username, name, e-mail, password)
+// → the venue (kind, name, staff language and time zone: the wizard switches to the language at
+// once) → a PIN for the lock screen (optional) → done: the venue is set up and you sign in.
+import { useState } from 'react'
+import { useMutation, useQueryClient } from '@tanstack/react-query'
+import { useNavigate } from 'react-router-dom'
+import { ArrowRight, Beer, CheckCircle2, ChevronLeft, Coffee, ShoppingBag, UtensilsCrossed } from 'lucide-react'
+import { errorMessage } from '@xenia/api'
+import { LANGUAGE_NAMES, useTranslation } from '@xenia/i18n'
+import { Button, Field, Input, Select, cx } from '@xenia/ui'
+import client from '../../api/client'
+import { browserTimeZone, timeZones } from '../Settings/sections/timeZones'
+import { VENUE_TYPES, accountProblems, pinProblems, setupBody, startLanguage, venueProblems } from './setupLogic'
+
+const ICONS = { restaurant: UtensilsCrossed, bar: Beer, coffee_shop: Coffee, fast_food: ShoppingBag }
+const STEPS = ['welcome', 'account', 'venue', 'pin', 'done']
+
+export default function SetupWizard() {
+ const { t, i18n } = useTranslation('manager')
+ const navigate = useNavigate()
+ const qc = useQueryClient()
+ const [step, setStep] = useState(0)
+ const [tried, setTried] = useState(false)
+ const [account, setAccount] = useState({ username: '', fullName: '', email: '', password: '', confirm: '' })
+ const [venue, setVenue] = useState(() => ({ types: [], name: '', language: startLanguage(typeof navigator !== 'undefined' ? navigator.language : ''), timezone: browserTimeZone() }))
+ const [pin, setPin] = useState({ pin: '', again: '' })
+ const problems = [[], accountProblems(account), venueProblems(venue), pinProblems(pin.pin, pin.again), []][step]
+ const err = k => { const p = tried && problems.find(([f]) => f === k); return p ? t(`setup.wrong.${p[1]}`) : undefined }
+ const next = () => { setTried(true); if (!problems.length) { setTried(false); setStep(s => s + 1) } }
+ const back = () => { setTried(false); setStep(s => s - 1) }
+ const setLanguage = lang => { setVenue(v => ({ ...v, language: lang })); i18n.changeLanguage(lang) }
+ const finish = useMutation({
+ mutationFn: () => client.post('/api/setup/init', setupBody(account, venue, pin.pin)),
+ onSuccess: () => { qc.setQueryData(['setup-status'], { needs_setup: false }); navigate('/login', { replace: true }) },
+ })
+ const name = STEPS[step]
+ return (
+
+
+
+ {step >= 1 && step <= 3 && (
+
+ {[1, 2, 3].map(i => )}
+
+ )}
+
+ {name === 'welcome' && (
+
+
+
+
{t('setup.welcome')}
+
{t('setup.welcomeIntro')}
+
+
+ {['account', 'venue', 'ready'].map((k, i) => (
+ -
+ {i + 1}{t(`setup.plan.${k}`)}
+
+ ))}
+
+
+ {Object.entries(LANGUAGE_NAMES).map(([code, label]) => (
+ setLanguage(code)} data-testid={`setup-lang-${code}`}>{label}
+ ))}
+
+
} onClick={next} data-testid="setup-start">{t('setup.start')}
+
+ )}
+
+ {name === 'account' && (
+
+ )}
+
+ {name === 'venue' && (
+
+
+
+
+ {VENUE_TYPES.map(k => {
+ const Icon = ICONS[k]
+ const on = venue.types.includes(k)
+ return (
+ setVenue(v => ({ ...v, types: on ? v.types.filter(x => x !== k) : [...v.types, k] }))}
+ className={cx('relative grid justify-items-center gap-2 rounded-card border-2 p-4 text-label font-medium transition-colors',
+ on ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface text-ink-2 hover:bg-surface-2')}>
+ {on && }
+ {t(`setup.kinds.${k}`)}
+
+ )
+ })}
+
+
+
+ setVenue(v => ({ ...v, name: e.target.value }))} data-testid="setup-venue-name" />
+
+
+
+
+
+
+
+
{t('setup.languageHint')}
+
+
+ )}
+
+ {name === 'pin' && (
+
+ )}
+
+ {name === 'done' && (
+
+
+
+
{t('setup.doneTitle')}
+
{t('setup.doneIntro')}
+
+
+ {['menu', 'tables', 'staff'].map(k => - {t(`setup.next3.${k}`)}
)}
+
+ {finish.error &&
{errorMessage(finish.error, t)}
}
+
+ } onClick={back} disabled={finish.isPending}>{t('setup.back')}
+ finish.mutate()} data-testid="setup-finish">{t('setup.finish')}
+
+
+ )}
+
+
{t('setup.footer')}
+
+
+ )
+}
+
+function Header({ title, intro }) {
+ return (
+
+ )
+}
+
+function Nav({ onBack, onNext, next }) {
+ const { t } = useTranslation('manager')
+ return (
+
+ } onClick={onBack}>{t('setup.back')}
+ {next ?? t('setup.next')}
+
+ )
+}
diff --git a/manager_dashboard/src/pages/setup/setupLogic.js b/manager_dashboard/src/pages/setup/setupLogic.js
new file mode 100644
index 0000000..82d7185
--- /dev/null
+++ b/manager_dashboard/src/pages/setup/setupLogic.js
@@ -0,0 +1,45 @@
+// The setup wizard's checks (plan step 6.14b), unit-tested in tests/shell.test.mjs.
+
+export const VENUE_TYPES = ['restaurant', 'bar', 'coffee_shop', 'fast_food']
+
+/** The account step: [field, problem] pairs. */
+export function accountProblems(a) {
+ const out = []
+ if (!a.username.trim()) out.push(['username', 'required'])
+ else if (/\s/.test(a.username.trim())) out.push(['username', 'spaces'])
+ if (!a.fullName.trim()) out.push(['fullName', 'required'])
+ if (a.email.trim() && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.email.trim())) out.push(['email', 'email'])
+ if (a.password.length < 6) out.push(['password', 'short'])
+ if (a.password !== a.confirm) out.push(['confirm', 'mismatch'])
+ return out
+}
+
+/** The venue step. */
+export function venueProblems(v) {
+ const out = []
+ if (!v.types.length) out.push(['types', 'pickOne'])
+ if (!v.name.trim()) out.push(['name', 'required'])
+ return out
+}
+
+/** The PIN step: empty (no PIN) or 4 to 6 digits, typed twice. */
+export function pinProblems(pin, again) {
+ if (!pin && !again) return []
+ if (!/^\d{4,6}$/.test(pin)) return [['pin', 'pin']]
+ if (pin !== again) return [['again', 'pinMismatch']]
+ return []
+}
+
+/** What POST /api/setup/init takes. */
+export function setupBody(a, v, pin) {
+ return {
+ username: a.username.trim(), password: a.password, email: a.email.trim() || null, full_name: a.fullName.trim(),
+ venue_type: v.types.join(','), venue_name: v.name.trim(), language: v.language, timezone: v.timezone,
+ pin: pin || undefined,
+ }
+}
+
+/** The staff language to start from: Greek when the browser is Greek, else English. */
+export function startLanguage(browserLanguage) {
+ return String(browserLanguage ?? '').toLowerCase().startsWith('el') ? 'el' : 'en'
+}
diff --git a/manager_dashboard/src/pages/tables/TableDialogs.jsx b/manager_dashboard/src/pages/tables/TableDialogs.jsx
new file mode 100644
index 0000000..d8e8f02
--- /dev/null
+++ b/manager_dashboard/src/pages/tables/TableDialogs.jsx
@@ -0,0 +1,180 @@
+// The dialogs of Management → Tables → List (plan step 6.14b): a table, a zone, many tables at
+// once, moving picked tables to a zone, renaming them in a series.
+import { useState } from 'react'
+import { useMutation } from '@tanstack/react-query'
+import toast from 'react-hot-toast'
+import { Trash2 } from 'lucide-react'
+import { errorMessage } from '@xenia/api'
+import { useTranslation } from '@xenia/i18n'
+import { Button, Dialog, Field, Input, Select, cx } from '@xenia/ui'
+import client from '../../api/client'
+import { CATEGORY_COLOURS } from '../products/categoryColours'
+import { MAX_NAME, nextNumber, series, tableBody, tableProblems } from './tablesLogic'
+
+const ZONE_COLOURS = CATEGORY_COLOURS.slice(0, 10) // the venue's colours (data), as for categories
+
+function useSave(fn, done, onSaved) {
+ const { t } = useTranslation('manager')
+ return useMutation({ mutationFn: fn, onSuccess: r => { toast.success(done(r)); onSaved() }, onError: e => toast.error(errorMessage(e, t)) })
+}
+
+const zoneOptions = (zones, t) => [{ value: '', label: t('tablesList.noZone') }, ...zones.map(z => ({ value: String(z.id), label: z.prefix ? `${z.name} (${z.prefix})` : z.name }))]
+
+export function TableDialog({ table, zones, zoneId, onClose, onSaved }) {
+ const { t } = useTranslation('manager')
+ const isNew = !table
+ const [form, setForm] = useState({ label: table?.label ?? '', group_id: String(table?.group_id ?? zoneId ?? ''), seats: table?.seat_count != null ? String(table.seat_count) : '' })
+ const [tried, setTried] = useState(false)
+ const set = (k, v) => setForm(f => ({ ...f, [k]: v }))
+ const wrong = tableProblems(form)
+ const save = useSave(body => (isNew ? client.post('/api/tables/', body) : client.put(`/api/tables/${table.id}`, body)), () => t(isNew ? 'tablesList.added' : 'tablesList.saved'), onSaved)
+ const submit = () => { setTried(true); if (!wrong.length) save.mutate(tableBody(form)) }
+ return (
+
+ )
+}
+
+export function ZoneDialog({ zone, onClose, onSaved }) {
+ const { t } = useTranslation('manager')
+ const isNew = !zone.id
+ const [form, setForm] = useState({ name: zone.name ?? '', prefix: zone.prefix ?? '', color: zone.color ?? null })
+ const [tried, setTried] = useState(false)
+ const [removing, setRemoving] = useState(false)
+ const set = (k, v) => setForm(f => ({ ...f, [k]: v }))
+ const body = () => ({ name: form.name.trim(), prefix: form.prefix.trim() || null, color: form.color })
+ const save = useSave(b => (isNew ? client.post('/api/tables/groups', b) : client.put(`/api/tables/groups/${zone.id}`, b)), () => t('tablesList.zoneSaved'), onSaved)
+ const remove = useSave(() => client.delete(`/api/tables/groups/${zone.id}`), () => t('tablesList.zoneDeleted'), onSaved)
+ const submit = () => { setTried(true); if (form.name.trim()) save.mutate(body()) }
+ if (removing) {
+ return (
+