feat(frontend): workday summary modal, print analytics UI, staff zone-PIN management, report upgrades

manager_dashboard:
- DashboardPage: WorkdaySummaryModal integration (view / close-day flows); revenue chart upgrades
- WorkdaySummaryModal: new component — shows full shift/revenue summary before closing the day
- StaffTab: full rewrite — zone-assignment modal, reset-PIN modal, actions dropdown, richer staff card
- ProductsTab: digital-menu fields surfaced in product form
- PrintFontsTab: expanded font-size/weight controls per printer channel
- TablesConfigTab / TablesPage / tableColourStore: color picker and zone fields for tables
- FilterBar: unified filter component with date-range, printer, and category selectors
- CategoryPerformance / ProductPerformance / TableAnalytics: donut/bar charts,
  thermal+browser print modals, richer breakdown tables
- PrinterHistory: redesigned with per-printer drill-down and summary blocks
- TrafficAnalytics / WorkDaySummary / RevenueTrends / ShiftsOverview / StaffLeaderboard: polish pass
- tokens.js: design token updates

waiter_pwa:
- TableCard: show table color indicator from zone/colour config

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 20:28:23 +03:00
co-authored by Claude Sonnet 4.6
parent 79bd3b0f41
commit ac7ec45279
21 changed files with 3352 additions and 644 deletions
@@ -636,7 +636,7 @@ function SubCatBar({ parentCat, subCats, products, subCatFilter, setSubCatFilter
}
// ── Bulk bar ──────────────────────────────────────────────────────────────────
function BulkBar({ count, onClear, onAvail, onUnavail, onArchive }) {
function BulkBar({ count, onClear, onAvail, onUnavail, onArchive, onSetPrinterZone, onMoveToCategory }) {
return (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', margin: '12px 24px 0', padding: '10px 14px', background: '#111827', color: '#fff', borderRadius: 10, flexShrink: 0 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
@@ -645,7 +645,7 @@ function BulkBar({ count, onClear, onAvail, onUnavail, onArchive }) {
</button>
<span style={{ fontSize: 13, fontWeight: 500 }}>{count} επιλεγμένα</span>
</div>
<div style={{ display: 'flex', gap: 4 }}>
<div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
{[
{ label: 'Διαθέσιμα', icon: 'eye', action: onAvail },
{ label: 'Μη διαθέσιμα', icon: 'eyeOff', action: onUnavail },
@@ -659,6 +659,111 @@ function BulkBar({ count, onClear, onAvail, onUnavail, onArchive }) {
{label}
</button>
))}
<div style={{ width: 1, background: 'rgba(255,255,255,0.15)', margin: '4px 2px' }} />
<button onClick={onSetPrinterZone}
style={{ border: '1px solid rgba(255,255,255,0.2)', background: 'transparent', color: 'rgba(255,255,255,0.85)', padding: '6px 10px', borderRadius: 6, fontSize: 13, fontWeight: 500, cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 6 }}
className="hover:bg-white/10"
>
<Icon name="folder" size={13} />
Ζώνη εκτύπωσης
</button>
<button onClick={onMoveToCategory}
style={{ border: '1px solid rgba(255,255,255,0.2)', background: 'transparent', color: 'rgba(255,255,255,0.85)', padding: '6px 10px', borderRadius: 6, fontSize: 13, fontWeight: 500, cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 6 }}
className="hover:bg-white/10"
>
<Icon name="move" size={13} />
Μετακίνηση
</button>
</div>
</div>
)
}
// ── Bulk: Set Printer Zone modal ───────────────────────────────────────────────
function BulkSetPrinterZoneModal({ count, printers, onClose, onConfirm }) {
const zones = [...new Map(printers.map(p => [p.id, p])).values()]
const [selectedId, setSelectedId] = useState(zones[0]?.id ?? '')
return (
<div style={{ position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 60, padding: 16 }}>
<div style={{ background: '#fff', borderRadius: 16, boxShadow: '0 20px 60px rgba(0,0,0,0.18)', width: '100%', maxWidth: 380, padding: 24 }}>
<h2 style={{ margin: '0 0 4px', fontWeight: 700, fontSize: 16, color: '#111827' }}>Ζώνη εκτύπωσης</h2>
<p style={{ margin: '0 0 18px', fontSize: 13, color: '#6b7280' }}>
Θα οριστεί σε <strong style={{ color: '#111827' }}>{count}</strong> προϊόντα.
</p>
{zones.length === 0 ? (
<p style={{ fontSize: 13, color: '#ef4444', marginBottom: 18 }}>Δεν βρέθηκαν εκτυπωτές.</p>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 20 }}>
{zones.map(z => (
<label key={z.id} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '10px 12px', border: `1.5px solid ${selectedId === z.id ? '#3b82f6' : '#e5e7eb'}`, borderRadius: 10, cursor: 'pointer', background: selectedId === z.id ? '#eff6ff' : '#fff' }}>
<input type="radio" name="zone" value={z.id} checked={selectedId === z.id} onChange={() => setSelectedId(z.id)} style={{ display: 'none' }} />
<span style={{ width: 16, height: 16, borderRadius: '50%', border: `2px solid ${selectedId === z.id ? '#3b82f6' : '#d1d5db'}`, background: selectedId === z.id ? '#3b82f6' : '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}>
{selectedId === z.id && <span style={{ width: 6, height: 6, borderRadius: '50%', background: '#fff' }} />}
</span>
<span style={{ fontSize: 14, fontWeight: 500, color: '#111827' }}>{z.name}</span>
</label>
))}
</div>
)}
<div style={{ display: 'flex', gap: 10 }}>
<button onClick={onClose} style={{ flex: 1, padding: '9px 0', border: '1px solid #e5e7eb', background: '#fff', borderRadius: 8, fontSize: 14, cursor: 'pointer', color: '#374151' }}>Άκυρο</button>
<button
onClick={() => onConfirm(selectedId)}
disabled={!selectedId}
style={{ flex: 1, padding: '9px 0', border: 'none', background: selectedId ? '#111827' : '#d1d5db', color: '#fff', borderRadius: 8, fontSize: 14, fontWeight: 600, cursor: selectedId ? 'pointer' : 'not-allowed' }}
>
Εφαρμογή
</button>
</div>
</div>
</div>
)
}
// ── Bulk: Move to Category modal ───────────────────────────────────────────────
function BulkMoveToCategoryModal({ count, categories, onClose, onConfirm }) {
const topLevel = categories.filter(c => !c.parent_id).sort((a, b) => a.sort_order - b.sort_order)
const [selectedId, setSelectedId] = useState('')
return (
<div style={{ position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.45)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 60, padding: 16 }}>
<div style={{ background: '#fff', borderRadius: 16, boxShadow: '0 20px 60px rgba(0,0,0,0.18)', width: '100%', maxWidth: 400, padding: 24 }}>
<h2 style={{ margin: '0 0 4px', fontWeight: 700, fontSize: 16, color: '#111827' }}>Μετακίνηση σε κατηγορία</h2>
<p style={{ margin: '0 0 18px', fontSize: 13, color: '#6b7280' }}>
Θα μετακινηθούν <strong style={{ color: '#111827' }}>{count}</strong> προϊόντα.
</p>
<div style={{ maxHeight: 280, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 4, marginBottom: 20 }}>
{topLevel.map(cat => {
const subs = categories.filter(c => c.parent_id === cat.id).sort((a, b) => a.sort_order - b.sort_order)
return (
<div key={cat.id}>
<label style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '9px 12px', border: `1.5px solid ${selectedId === cat.id ? cat.color || '#3b82f6' : '#e5e7eb'}`, borderRadius: 9, cursor: 'pointer', background: selectedId === cat.id ? '#f8faff' : '#fff' }}>
<input type="radio" name="cat" value={cat.id} checked={selectedId === cat.id} onChange={() => setSelectedId(cat.id)} style={{ display: 'none' }} />
<span style={{ width: 10, height: 10, borderRadius: '50%', background: cat.color || '#94a3b8', flexShrink: 0 }} />
<span style={{ fontSize: 13.5, fontWeight: 600, color: '#111827', flex: 1 }}>{cat.name}</span>
{selectedId === cat.id && <Icon name="check" size={14} className="text-blue-500" />}
</label>
{subs.map(sub => (
<label key={sub.id} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '8px 12px 8px 28px', border: `1.5px solid ${selectedId === sub.id ? sub.color || '#3b82f6' : '#e5e7eb'}`, borderRadius: 8, cursor: 'pointer', background: selectedId === sub.id ? '#f8faff' : '#fff', marginTop: 3 }}>
<input type="radio" name="cat" value={sub.id} checked={selectedId === sub.id} onChange={() => setSelectedId(sub.id)} style={{ display: 'none' }} />
<span style={{ width: 7, height: 7, borderRadius: '50%', background: sub.color || '#94a3b8', flexShrink: 0 }} />
<span style={{ fontSize: 13, fontWeight: 500, color: '#374151', flex: 1 }}>{sub.name}</span>
{selectedId === sub.id && <Icon name="check" size={13} className="text-blue-500" />}
</label>
))}
</div>
)
})}
</div>
<div style={{ display: 'flex', gap: 10 }}>
<button onClick={onClose} style={{ flex: 1, padding: '9px 0', border: '1px solid #e5e7eb', background: '#fff', borderRadius: 8, fontSize: 14, cursor: 'pointer', color: '#374151' }}>Άκυρο</button>
<button
onClick={() => onConfirm(selectedId)}
disabled={!selectedId}
style={{ flex: 1, padding: '9px 0', border: 'none', background: selectedId ? '#111827' : '#d1d5db', color: '#fff', borderRadius: 8, fontSize: 14, fontWeight: 600, cursor: selectedId ? 'pointer' : 'not-allowed' }}
>
Μετακίνηση
</button>
</div>
</div>
</div>
)
@@ -938,6 +1043,8 @@ export default function ProductsTab() {
const [collapsedGroups, setCollapsedGroups] = useState(new Set())
// local override of group display order (array of group keys), reset when scope changes
const [localGroupOrder, setLocalGroupOrder] = useState(null)
const [bulkPrinterZoneModal, setBulkPrinterZoneModal] = useState(false)
const [bulkMoveCatModal, setBulkMoveCatModal] = useState(false)
// drag state for group headers
const groupDragId = useRef(null)
@@ -1163,6 +1270,26 @@ export default function ProductsTab() {
setConfirmDelete(null); invalidate(); clearSelect()
}
async function handleBulkSetPrinterZone(printerId) {
const ids = [...selected]
setBulkPrinterZoneModal(false)
try {
await Promise.all(ids.map(id => client.put(`/api/products/${id}`, { printer_zone_id: printerId })))
toast.success(`Ζώνη εκτύπωσης ορίστηκε σε ${ids.length} προϊόντα`)
invalidate(); clearSelect()
} catch { toast.error('Σφάλμα') }
}
async function handleBulkMoveToCategory(categoryId) {
const ids = [...selected]
setBulkMoveCatModal(false)
try {
await Promise.all(ids.map(id => client.put(`/api/products/${id}`, { category_id: categoryId })))
toast.success(`${ids.length} προϊόντα μετακινήθηκαν`)
invalidate(); clearSelect()
} catch { toast.error('Σφάλμα') }
}
function handleConfirmDelete() {
if (!confirmDelete) return
if (confirmDelete.type === 'category') deleteCat.mutate(confirmDelete.id)
@@ -1345,6 +1472,8 @@ export default function ProductsTab() {
onAvail={() => bulkAction('available')}
onUnavail={() => bulkAction('unavailable')}
onArchive={() => bulkAction('archive')}
onSetPrinterZone={() => setBulkPrinterZoneModal(true)}
onMoveToCategory={() => setBulkMoveCatModal(true)}
/>
)}
@@ -1500,6 +1629,26 @@ export default function ProductsTab() {
onCancel={() => setConfirmDelete(null)}
/>
)}
{/* Bulk: set printer zone modal */}
{bulkPrinterZoneModal && (
<BulkSetPrinterZoneModal
count={selected.size}
printers={printers}
onClose={() => setBulkPrinterZoneModal(false)}
onConfirm={handleBulkSetPrinterZone}
/>
)}
{/* Bulk: move to category modal */}
{bulkMoveCatModal && (
<BulkMoveToCategoryModal
count={selected.size}
categories={categories}
onClose={() => setBulkMoveCatModal(false)}
onConfirm={handleBulkMoveToCategory}
/>
)}
</div>
)
}