diff --git a/manager_dashboard/src/pages/floor/FloorEditor.jsx b/manager_dashboard/src/pages/floor/FloorEditor.jsx index 01c78e0..bace9ed 100644 --- a/manager_dashboard/src/pages/floor/FloorEditor.jsx +++ b/manager_dashboard/src/pages/floor/FloorEditor.jsx @@ -7,21 +7,26 @@ // corner; resting on a corner shows a bubble to remove it (a floor keeps at least 3). An area // (2026-11-20) is resized by the handles on its sides and corners, and has a colour (pastel, see- // through); when tables cover its name, the name shows in its corner too. +// 2026-11-21: the "+" on an edge hides near a corner (there the corner's bubble removes it); +// minus / fit width / whole plan / plus; "Edit the floor's shape" is a button that turns into +// "Save shape" (saves the shape and the floor's size at once, nothing else); every unrotated table +// or thing has resize handles, and sizes are in grid cells (half cells), so they follow the grid +// resolution picked; a wall's thickness in steps. // Arrow keys move the selected thing (a grid cell, or 5; Shift: 1), Delete takes it off, Escape // lets go. Nothing is saved until "Save"; then every app's map changes at once. import { useLayoutEffect, useMemo, useRef, useState } from 'react' import toast from 'react-hot-toast' -import { RotateCcw, RotateCw, Save, Trash2, Undo2 } from 'lucide-react' +import { Check, Minus, PenTool, Plus, RotateCcw, RotateCw, Save, Trash2, Undo2 } from 'lucide-react' import { errorMessage } from '@xenia/api' import { AREA_COLOURS, Floor, GRID_LEVELS, ITEM_KINDS, Item, SHAPES, TableShape, addCornerAt, coveredAreas, defaultSize, moveCorner, moveTo, nearestEdge, outlineOf, removeCorner, resizeBox, toPlan, } from '@xenia/floorplan' import { useTranslation } from '@xenia/i18n' -import { Button, Dialog, Dropdown, Field, IconButton, Input, Segmented, Switch, cx } from '@xenia/ui' +import { Button, Dialog, Dropdown, Field, IconButton, Input, Segmented, Stepper, Switch, cx } from '@xenia/ui' import MediaField from '../media/MediaField' import * as api from './floorApi' -import { addItem, addable, find, fitOutline, layoutBody, layoutOf, nudge, placeTable, planBody, remove, resize, rotate, sameLayout, update } from './editorLogic' +import { WALL_THICKNESS, addItem, addable, cellOf, find, fitOutline, layoutBody, layoutOf, nudge, placeTable, planBody, remove, resizeCells, rotate, sameLayout, toCells, update } from './editorLogic' const PAD = 30 // room around the floor for the corner handles const HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'] @@ -44,6 +49,7 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele const { t } = useTranslation('manager') const initial = useMemo(() => layoutOf(data, saved.id), [data, saved.id]) const [layout, setLayout] = useState(initial) + const [base, setBase] = useState(saved) // the plan as saved (a saved shape updates it) const [form, setForm] = useState(() => ({ ...saved })) const [sel, setSel] = useState(null) // {type: 'table'|'item', id} | {type: 'corner', index} const [shapeMode, setShapeMode] = useState(false) @@ -51,6 +57,8 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele const [busy, setBusy] = useState(false) const [deleting, setDeleting] = useState(false) const [fit, setFit] = useState('width') // 'width' | 'all' + const [zoom, setZoom] = useState(null) // a scale picked with − / + (null: the fit) + const [shapeBusy, setShapeBusy] = useState(false) const [edgeHover, setEdgeHover] = useState(null) // where a click on the edge adds a corner const [cornerTip, setCornerTip] = useState(null) // the corner showing its "remove" bubble const tipTimer = useRef(null) @@ -60,7 +68,7 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele const size = useSize(box) const plan = form // the preview follows the unsaved settings - const dirtySettings = JSON.stringify(planBody(form)) !== JSON.stringify(planBody(saved)) + const dirtySettings = JSON.stringify(planBody(form)) !== JSON.stringify(planBody(base)) const dirty = dirtySettings || !sameLayout(layout, initial) const selected = sel && sel.type !== 'corner' ? find(layout, sel) : null const corners = outlineOf(plan) @@ -71,7 +79,9 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele // the scale: the plan (and its margin) fitted to the width, or whole in the box const vbW = plan.width + 2 * PAD const vbH = plan.height + 2 * PAD - const scale = size.width ? (fit === 'all' && size.height ? Math.min(size.width / vbW, size.height / vbH) : size.width / vbW) : 1 + const fitScale = size.width ? (fit === 'all' && size.height ? Math.min(size.width / vbW, size.height / vbH) : size.width / vbW) : 1 + const scale = zoom ?? fitScale + const zoomBy = f => setZoom(Math.min(4, Math.max(0.1, scale * f))) const r = Math.max(8, 9 / scale) // a handle's size on screen ≈ 18 px const point = e => toPlan(svg.current, e.clientX, e.clientY) @@ -96,7 +106,9 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele const [px, py] = point(e) if (!d) { if (shapeMode) { - const n = nearestEdge(corners, [px, py]) + // near a corner there is no "+": that corner's bubble removes it + const nearCorner = corners.some(([x, y]) => Math.hypot(x - px, y - py) < r * 3) + const n = nearCorner ? null : nearestEdge(corners, [px, py]) setEdgeHover(n && n.d < 14 / scale ? n : null) } return @@ -106,7 +118,7 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele return } if (d.target.handle) { - setLayout(l => update(l, d.target, resizeBox(find(l, d.target), d.target.handle, px, py, plan))) + setLayout(l => update(l, d.target, resizeBox(find(l, d.target), d.target.handle, px, py, plan, cellOf(plan) / 2))) return } setLayout(l => { @@ -148,10 +160,27 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele onSaved() } catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) } } + const enterShape = () => { setShapeMode(true); setSel(null); setEdgeHover(null); setCornerTip(null) } + const leaveShape = () => { setShapeMode(false); setEdgeHover(null); setCornerTip(null); setSel(null) } + // "Save shape": the floor's shape and size are saved at once; the rest waits for "Save" + const saveShape = async () => { + const shape = { outline: form.outline ?? null, width: form.width, height: form.height } + if (JSON.stringify(planBody({ ...base, ...shape })) !== JSON.stringify(planBody(base))) { + setShapeBusy(true) + try { + await api.savePlan(saved.id, planBody({ ...base, ...shape })) + setBase(b => ({ ...b, ...shape })) + toast.success(t('floor.shapeSaved')) + } catch (err) { toast.error(errorMessage(err, t)); setShapeBusy(false); return } + setShapeBusy(false) + } + leaveShape() + } const zoneName = id => groups.find(g => g.id === id)?.name ?? t('floor.noZone') const gridOptions = [...GRID_LEVELS.map(([k, v]) => ({ value: v, label: t(`floor.gridLevels.${k}`), hint: t('floor.gridCell', { size: v }) })), ...(GRID_LEVELS.some(([, v]) => v === form.grid_size) ? [] : [{ value: form.grid_size, label: t('floor.gridCell', { size: form.grid_size }) }])] - const resizable = selected && sel.type === 'item' && selected.kind === 'area' && !shapeMode && Math.round(selected.rotation || 0) % 180 === 0 + const resizable = selected && !shapeMode && Math.round(selected.rotation || 0) % 180 === 0 + const handles = resizable && selected.kind === 'wall' ? ['e', 'w'] : HANDLES return (
@@ -164,16 +193,27 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele {form.grid_on && ( setF('grid_size', v)} aria-label={t('floor.gridSize')} data-testid="floor-grid-size" options={gridOptions} /> )} - { setShapeMode(v); setSel(null); setEdgeHover(null); setCornerTip(null) }} label={t('floor.editShape')} data-testid="floor-shape-mode" /> - + {shapeMode ? ( + + + + + ) : ( + + )} + + zoomBy(1 / 1.25)} data-testid="floor-zoom-out"> + { setFit(v); setZoom(null) }} aria-label={t('floor.fit')} + options={[{ value: 'width', label: t('floor.fitWidth'), testId: 'floor-fit-width' }, { value: 'all', label: t('floor.fitAll'), testId: 'floor-fit-all' }]} /> + zoomBy(1.25)} data-testid="floor-zoom-in"> + + onClick={() => { setLayout(initial); setForm({ ...base }); setSel(null) }}>{t('floor.undoAll')}
-
start(e, { type: 'table', id: tb.id })} data-testid="floor-table" /> ))} - {resizable && HANDLES.map(h => { + {resizable && handles.map(h => { const x = selected.x + (h.includes('e') ? 1 : h.includes('w') ? -1 : 0) * selected.width / 2 const y = selected.y + (h.includes('s') ? 1 : h.includes('n') ? -1 : 0) * selected.height / 2 return ( start(e, { type: 'item', id: sel.id, handle: h })} /> + onPointerDown={e => start(e, { ...sel, handle: h })} /> ) })} {shapeMode && edgeHover && ( @@ -342,7 +382,7 @@ function TableButtons({ tables, title, onAdd, quiet = false }) { function Selected({ thing, sel, plan, t, onChange, onRemove }) { const isTable = sel.type === 'table' const isArea = !isTable && thing.kind === 'area' - const setSize = (w, h) => onChange(resize(thing, plan, w, h)) + const cells = v => t('floor.cells', { count: v, value: String(v).replace('.', t('floor.decimal')) }) return ( {isTable && ( @@ -386,9 +426,21 @@ function Selected({ thing, sel, plan, t, onChange, onRemove }) {

{t('floor.areaResizeHint')}

) : ( -
- setSize(Number(e.target.value), undefined)} /> - setSize(undefined, Number(e.target.value))} /> + // sizes in grid cells, by half cells (2026-11-21); a wall's thickness in steps +
+
+ {t(thing.kind === 'wall' ? 'floor.length' : 'floor.itemWidth')} + onChange(resizeCells(thing, plan, v, null))} data-testid="floor-width" /> +
+
+ {t(thing.kind === 'wall' ? 'floor.thickness' : 'floor.itemHeight')} + {thing.kind === 'wall' + ? `${v} px`} label={t('floor.thickness')} onChange={v => onChange({ height: v })} /> + : onChange(resizeCells(thing, plan, null, v))} data-testid="floor-height" />} +
+

{t('floor.cellsHint')}

)}
diff --git a/manager_dashboard/src/pages/floor/editorLogic.js b/manager_dashboard/src/pages/floor/editorLogic.js index 159e925..0209d77 100644 --- a/manager_dashboard/src/pages/floor/editorLogic.js +++ b/manager_dashboard/src/pages/floor/editorLogic.js @@ -92,6 +92,23 @@ export function resize(thing, plan, width, height) { return { width: w, height: h } } +/** Sizes in grid cells (2026-11-21): one cell is the plan's grid size (also while the grid is + * hidden), counted in half cells, so a table follows the grid resolution picked. */ +export const cellOf = plan => plan.grid_size || 40 +export const toCells = (v, plan) => Math.max(0.5, Math.round((v / cellOf(plan)) * 2) / 2) + +/** A new size in cells (null: that side unchanged); the centre stays on the grid. */ +export function resizeCells(thing, plan, wCells, hCells) { + const c = cellOf(plan) + const width = wCells != null ? Math.max(0.5, wCells) * c : thing.width + const height = hCells != null ? Math.max(0.5, hCells) * c : thing.height + const m = moveTo({ ...thing, width, height }, thing.x, thing.y, plan) + return { width, height, x: m.x, y: m.y } +} + +/** A wall's thickness, in steps (px). */ +export const WALL_THICKNESS = [4, 6, 8, 12, 16, 20, 24, 32] + /** A rotation turned by `by` degrees, kept within 0–359. */ export const rotate = (deg, by) => (((deg + by) % 360) + 360) % 360 diff --git a/manager_dashboard/src/pages/media/MediaField.jsx b/manager_dashboard/src/pages/media/MediaField.jsx index e4b1a10..d24bbcf 100644 --- a/manager_dashboard/src/pages/media/MediaField.jsx +++ b/manager_dashboard/src/pages/media/MediaField.jsx @@ -2,6 +2,7 @@ // Upload → into the library and set here at once ("upload on the spot") // From library → the picker // Remove → nothing here any more (the photo stays in the library) +// Layout (2026-11-21): the two buttons, the picture's name under them, then Remove. // After an upload on the spot, "Name it after " sets the photo's display name to // `nameAfter` in Latin letters (latin() from @xenia/i18n). The file names on disk are the backend's. // @@ -51,15 +52,16 @@ export default function MediaField({ value, onChange, nameAfter, nameAfterLabel,
- {value && {value.name}}
- {value && }
+ {/* 2026-11-21: the picture's name under the buttons, then "Remove" (red under the pointer) */} + {value && {value.name}} + {value && } {value && fresh === value.id && suggested && suggested !== value.name && ( -
+
+ } onClick={() => setEdit(blankRule())} data-testid="channel-price-new">{t('pricing.channels.new')}} /> {isPending ?
: !list.length ? : ( @@ -91,7 +90,7 @@ export default function ChannelPricesTab() {

{t('pricing.channels.removeBody')}

)} -
+ ) } diff --git a/manager_dashboard/src/pages/pricing/DiscountsTab.jsx b/manager_dashboard/src/pages/pricing/DiscountsTab.jsx index 7755ae7..126b9a5 100644 --- a/manager_dashboard/src/pages/pricing/DiscountsTab.jsx +++ b/manager_dashboard/src/pages/pricing/DiscountsTab.jsx @@ -21,7 +21,7 @@ const UNIT = { max_discount_percent: '%', max_discount_amount: '€', max_total_ export default function DiscountsTab() { const { t } = useTranslation('manager') return ( -
+
@@ -73,7 +73,7 @@ function VenueForm({ data, onSaved, t }) { } catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) } } return ( -
+

{t('pricing.discounts.venue')}

{t('pricing.discounts.venueHint')}

@@ -95,7 +95,7 @@ function PersonLimits() { const id = chosen ?? people[0]?.id ?? null const { data } = useLiveQuery({ queryKey: ['pricing', 'person-limits', id], queryFn: () => api.waiterLimits(id), enabled: !!id, events: api.PRICING_EVENTS }) return ( -
+

{t('pricing.discounts.person')}

{t('pricing.discounts.personHint')}

diff --git a/manager_dashboard/src/pages/pricing/PricingPage.jsx b/manager_dashboard/src/pages/pricing/PricingPage.jsx index c404a9e..9036c50 100644 --- a/manager_dashboard/src/pages/pricing/PricingPage.jsx +++ b/manager_dashboard/src/pages/pricing/PricingPage.jsx @@ -2,6 +2,8 @@ // limits and (2026-11-20) order channel prices, one tab each. Changes reach the counter, the phones // and the tablets at once: new prices apply to what is added to orders from then on (lines already // on an order keep their price). The tab is in the address (?tab=). +// 2026-11-21: the page's title and description first, then the tabs; each tab has its own head +// (title, description, its "New" button at the top right). import { useSearchParams } from 'react-router-dom' import { useTranslation } from '@xenia/i18n' import { Page, PageHeader, Tabs } from '@xenia/ui' @@ -19,10 +21,9 @@ export default function PricingPage() { const tab = TABS.includes(params.get('tab')) ? params.get('tab') : 'rules' const setTab = v => setParams(p => { const n = new URLSearchParams(p); n.set('tab', v); return n }, { replace: true }) return ( - } top={ ({ id: k, label: t(`pricing.tabs.${k}`), testId: `pricing-tab-${k}` }))} />}> - {tab === 'rules' && } {tab === 'channels' && } {tab === 'groups' && } diff --git a/manager_dashboard/src/pages/pricing/PricingParts.jsx b/manager_dashboard/src/pages/pricing/PricingParts.jsx index cf1e6fb..810cf94 100644 --- a/manager_dashboard/src/pages/pricing/PricingParts.jsx +++ b/manager_dashboard/src/pages/pricing/PricingParts.jsx @@ -271,12 +271,12 @@ export function RuleCard({ colour, name, active, badges, summary, description, o /** The tab's head: what it is, and its "New" button. */ export function TabHead({ title, intro, action }) { return ( -
-
+
+

{title}

-

{intro}

+

{intro}

- {action} + {action &&
{action}
}
) } diff --git a/manager_dashboard/src/pages/products/CategoryTree.jsx b/manager_dashboard/src/pages/products/CategoryTree.jsx index 6eb56c5..51fea23 100644 --- a/manager_dashboard/src/pages/products/CategoryTree.jsx +++ b/manager_dashboard/src/pages/products/CategoryTree.jsx @@ -4,9 +4,9 @@ // count is the products listed in it, so a product in two categories counts in both. The chosen // category's row shows its actions. import { useRef, useState } from 'react' -import { Archive, ArrowRightLeft, ChevronDown, ChevronRight, Folder, GripVertical, Pencil, Plus, Search, Trash2, Truck, X } from 'lucide-react' +import { Archive, ArrowRightLeft, ChevronDown, ChevronRight, Folder, GripVertical, Pencil, Plus, Trash2, Truck } from 'lucide-react' import { useTranslation } from '@xenia/i18n' -import { IconButton, Input, cx } from '@xenia/ui' +import { IconButton, Pane, SearchInput, cx } from '@xenia/ui' import { SCOPES, countIn, isArchived, moveId, subsOf, topLevel } from './productsLogic' export function Dot({ cat, size = 'w-2 h-2' }) { @@ -57,36 +57,34 @@ export default function CategoryTree({ categories, products, scope, onScope, onA ) return ( - +
}> + p.is_service_item).length} active={scope === SCOPES.service} onClick={() => onScope(SCOPES.service)} + dot={