diff --git a/client/src/tablet/Sale.tsx b/client/src/tablet/Sale.tsx index 7bd0fab..0d1739a 100644 --- a/client/src/tablet/Sale.tsx +++ b/client/src/tablet/Sale.tsx @@ -122,8 +122,14 @@ export function Sale({ config, onChangeBar }: Props) { addDrink(d.id); } + // Positive n adds (works on any drink, cart-empty or not). Negative n + // removes — routed through incLine rather than addDrink so it shares + // the qty-stepper's clamp-at-zero-and-drop-the-line behaviour instead + // of letting a line go negative (addDrink's raw `qty + n` would). function pickCount(n: number) { - if (pickerDrink) addDrink(pickerDrink.id, n); + if (!pickerDrink) return; + if (n > 0) addDrink(pickerDrink.id, n); + else incLine(pickerDrink.id, n); setPickerDrink(null); } @@ -191,23 +197,43 @@ export function Sale({ config, onChangeBar }: Props) { )} - {pickerDrink && ( -
setPickerDrink(null)}> -
e.stopPropagation()}> -
{pickerDrink.name}
-
- {PICKER_COUNTS.map(n => ( - - ))} + {pickerDrink && (() => { + // #70: "when there are already drinks in cart, i want to be able + // to remove them" — the remove row only makes sense (and only + // appears) once there's cart quantity for this drink to remove; + // an empty-cart drink keeps the original add-only picker. + const cartQty = lines.find(l => l.drink_id === pickerDrink.id)?.qty ?? 0; + return ( +
setPickerDrink(null)}> +
e.stopPropagation()}> +
{pickerDrink.name}
+
+ {PICKER_COUNTS.map(n => ( + + ))} +
+ {cartQty > 0 && ( +
+ {PICKER_COUNTS.map(n => ( + + ))} +
+ )} +
-
-
- )} + ); + })()}