// One item on an order card: quantity badge, name, changes (− removed, + extras, → choices)
// and its note. On the selected card a tap moves it on, a long press declines it.
import { useRef } from 'react'
import { ArrowRight, Hand, Info, Minus, Plus } from 'lucide-react'
import { dedupeModifiers, formatQty, hasUnit } from '../logic/board'
import { KDS } from '../theme'
const MOD_ICON_SZ = 13
const HOLD_MS = 500
export function ModRow({ Icon, color, text, done, fs }) {
const col = done ? KDS.cardMuted : color
const fontSize = Math.round(12 * fs)
const lineH = Math.round(fontSize * 1.4)
const iconSz = Math.round(MOD_ICON_SZ * fs)
return (
{/* one line tall, so the icon sits on the first line when the text wraps */}
{text}
)
}
export default function ItemBlock({ item, focused, onBump, onDecline, fontScale = 1, fontWeight = 600, combineModifiers }) {
const status = item.kds_status
const done = status === 'done' || status === 'served'
const preparing = status === 'preparing'
const fs = fontScale
const removed = dedupeModifiers(item.removed ?? [])
const extras = dedupeModifiers(item.extras ?? [])
const prefs = dedupeModifiers(item.prefs ?? [])
const hasMods = removed.length || extras.length || prefs.length || item.notes
const nameFontSize = Math.round(15 * fs)
const nameLineH = Math.round(nameFontSize * 1.4)
const badgeH = nameLineH
const hold = useRef(null)
const cancelHold = () => { if (hold.current) { clearTimeout(hold.current); hold.current = null } }
const onPointerDown = focused && onDecline ? e => {
e.stopPropagation()
hold.current = setTimeout(() => { hold.current = null; onDecline(item) }, HOLD_MS)
} : undefined
return (
{ e.stopPropagation(); cancelHold(); onBump?.(item) } : undefined}
onPointerDown={onPointerDown} onPointerUp={cancelHold} onPointerLeave={cancelHold} onPointerCancel={cancelHold}
style={{ borderRadius: 7, margin: '0 -5px', padding: '2px 5px', cursor: focused ? 'pointer' : 'default',
transition: 'background .1s', opacity: done ? 0.55 : 1, touchAction: 'none' }}
>
{formatQty(item.quantity, item.unit_type)}
{item.product_name}
{item.claimed_by_name && !done && (
{item.claimed_by_name}
)}
{focused && (
)}
{hasMods ? (
{combineModifiers ? (
<>
{removed.length > 0 && }
{extras.length > 0 && }
{prefs.length > 0 && }
>
) : (
<>
{removed.map((r, i) => )}
{extras.map((x, i) => )}
{prefs.map((p, i) => )}
>
)}
{item.notes && }
) : null}
)
}