feat(waiter): what a waiter may do comes from permission keys (platform-v2 step 4.3)
- Payments: ordering.orders.close checked on pay/close and the counter POS
(waiters have it by default, owner decision); pay-offline always recorded.
- The venue switches waiter_cancellations / price_adjust / revert are gone:
ordering.orders.cancel, ordering.prices.modify and the new
ordering.payments.revert (overridable) decide; moves/split/transfer/merge
need ordering.orders.open; discounts pricing.discounts.apply; chat chat.use.
- Venue role defaults: role_permissions (Alembic 0024), role_template(role, db),
GET/PUT /api/waiters/roles/{role}/permissions applying the change to everyone
with the role; manager Settings -> Operation -> "What each role may do".
0024 also grants the new key to existing owners and store managers.
- Bootstrap `approvable`; @xenia/access useAllowed(key) -> yes/approve/no.
The waiter shows each action by key, "with a manager's approval (PIN)" where
allowed; GET /api/orders/cancel-permissions removed.
- Tests: test_waiter_keys.py (11), access allowed(), waiter.mjs +5, manager.mjs +3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useNavigate, useLocation } from 'react-router-dom'
|
||||
import { useCan, useModule } from '@xenia/access'
|
||||
import UserMenu from './UserMenu'
|
||||
import { useNotifications } from '../context/NotificationContext'
|
||||
import useNotificationSettingsStore from '../store/notificationSettingsStore'
|
||||
@@ -96,6 +97,14 @@ const NAV_REGISTRY = {
|
||||
},
|
||||
}
|
||||
|
||||
/** Staff chat shows only when the venue has it on and the person holds chat.use (plan 4.3). */
|
||||
function useChatOn() {
|
||||
const on = useModule('chat')
|
||||
const can = useCan('chat.use')
|
||||
return on && can
|
||||
}
|
||||
const shown = chatOn => item => item.key !== 'messages' || chatOn
|
||||
|
||||
const DRAWER_ITEMS = [
|
||||
{ ...NAV_REGISTRY.tables },
|
||||
{ ...NAV_REGISTRY.orders },
|
||||
@@ -354,6 +363,7 @@ function DrawerButton({ item, location, onNavigate, active: activeProp, onClick
|
||||
|
||||
function SideDrawer({ open, onClose }) {
|
||||
const navigate = useNavigate()
|
||||
const chatOn = useChatOn()
|
||||
const location = useLocation()
|
||||
const { activeZoneTab, setActiveZoneTab } = useTableViewStore()
|
||||
|
||||
@@ -404,7 +414,7 @@ function SideDrawer({ open, onClose }) {
|
||||
<div style={{ fontSize: 10, fontWeight: 700, color: 'var(--muted)', textTransform: 'uppercase', letterSpacing: 1, padding: '4px 10px 8px' }}>
|
||||
Πλοήγηση
|
||||
</div>
|
||||
{DRAWER_NAV_ITEMS.map(item => {
|
||||
{DRAWER_NAV_ITEMS.filter(shown(chatOn)).map(item => {
|
||||
const isStandaloneActive = location.pathname === '/tables' && activeZoneTab === 'standalone'
|
||||
const active = item.key === 'standalone'
|
||||
? isStandaloneActive
|
||||
@@ -452,7 +462,8 @@ function PillBadge({ count, color = '#ef4444' }) {
|
||||
|
||||
function TripleFooter({ location, navigate, chatUnread, kdsReady, tripleItems }) {
|
||||
const { activeZoneTab, setActiveZoneTab } = useTableViewStore()
|
||||
const items = (tripleItems || ['tables', 'orders', 'messages']).map(k => NAV_REGISTRY[k]).filter(Boolean)
|
||||
const chatOn = useChatOn()
|
||||
const items = (tripleItems || ['tables', 'orders', 'messages']).map(k => NAV_REGISTRY[k]).filter(Boolean).filter(shown(chatOn))
|
||||
|
||||
function handleNavClick(item) {
|
||||
if (item.key === 'standalone') { setActiveZoneTab('standalone'); navigate('/tables', { replace: true }); return }
|
||||
@@ -516,9 +527,11 @@ function TripleFooter({ location, navigate, chatUnread, kdsReady, tripleItems })
|
||||
|
||||
function IconNavbar({ navItems, location, navigate, chatUnread, kdsReady }) {
|
||||
const { activeZoneTab, setActiveZoneTab } = useTableViewStore()
|
||||
const chatOn = useChatOn()
|
||||
const items = navItems
|
||||
.map(key => NAV_REGISTRY[key])
|
||||
.filter(Boolean)
|
||||
.filter(shown(chatOn))
|
||||
|
||||
function handleNavClick(item) {
|
||||
if (item.key === 'standalone') { setActiveZoneTab('standalone'); navigate('/tables', { replace: true }); return }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import { useCan } from '@xenia/access'
|
||||
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
|
||||
import { getVenueSettings } from '../api/venueSettings'
|
||||
import { assetUrl } from '../config/server'
|
||||
|
||||
// ── Helpers ──────────────────────────────────────────────────────────────────
|
||||
@@ -1047,13 +1047,9 @@ const FALLBACK_QUICK_NOTES = ['Χωρίς αλάτι', 'Βγάλτε γρήγο
|
||||
|
||||
export default function OrderDrawer({ product, isOpen, onClose, onAdd, initialState, courses, quickNotes }) {
|
||||
const itemFavorites = useWaiterFavoritesStore(s => s.itemFavorites)
|
||||
const [priceAdjAllowed, setPriceAdjAllowed] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
getVenueSettings()
|
||||
.then(r => setPriceAdjAllowed(r.data?.['orders.waiter_price_adjust_allowed']?.value === 'true'))
|
||||
.catch(() => {})
|
||||
}, [])
|
||||
// A price set before sending needs the key itself (plan 4.3); the manager-approval path for
|
||||
// it comes with server-priced orders (4.4). After sending, the item's actions offer it.
|
||||
const priceAdjAllowed = useCan('ordering.prices.modify')
|
||||
|
||||
const preferenceSets = product?.preference_sets || []
|
||||
const quickOptions = product?.quick_options || []
|
||||
|
||||
Reference in New Issue
Block a user