Fix modifier nesting - don't add intermediate groups
When user customizes an item, add selections directly under the root item instead of creating an intermediate group node. This matches how attachDefaultChildren works on the server and prevents duplicate modifiers showing in KDS. Before: Double Double → Customize Lettuce → Light, Extra After: Double Double → Light, Extra Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9a489f20bb
commit
f6428a14ff
1 changed files with 6 additions and 13 deletions
|
|
@ -1165,6 +1165,7 @@ class _MenuBrowseScreenState extends State<MenuBrowseScreen> {
|
||||||
final realChildItemId = _decodeVirtualId(child.itemId);
|
final realChildItemId = _decodeVirtualId(child.itemId);
|
||||||
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
|
// This item is directly selected - add it
|
||||||
final cart = await Api.setLineItem(
|
final cart = await Api.setLineItem(
|
||||||
orderId: orderId,
|
orderId: orderId,
|
||||||
parentOrderLineItemId: parentOrderLineItemId,
|
parentOrderLineItemId: parentOrderLineItemId,
|
||||||
|
|
@ -1186,21 +1187,13 @@ class _MenuBrowseScreenState extends State<MenuBrowseScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (hasSelectedDescendants) {
|
} else if (hasSelectedDescendants) {
|
||||||
final cart = await Api.setLineItem(
|
// This item is NOT selected, but has selected descendants
|
||||||
orderId: orderId,
|
// DON'T add this intermediate group - just recurse to add the actual selections
|
||||||
parentOrderLineItemId: parentOrderLineItemId,
|
// The selections will be added directly under the current parent
|
||||||
itemId: child.itemId,
|
// This matches how attachDefaultChildren works on the server
|
||||||
isSelected: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
final childLineItem = cart.lineItems.lastWhere(
|
|
||||||
(li) => li.itemId == realChildItemId && li.parentOrderLineItemId == parentOrderLineItemId && !li.isDeleted,
|
|
||||||
orElse: () => throw StateError('Failed to add item'),
|
|
||||||
);
|
|
||||||
|
|
||||||
await _addModifiersRecursively(
|
await _addModifiersRecursively(
|
||||||
orderId,
|
orderId,
|
||||||
childLineItem.orderLineItemId,
|
parentOrderLineItemId, // Keep the same parent - don't create intermediate node
|
||||||
child.itemId,
|
child.itemId,
|
||||||
selectedItemIds,
|
selectedItemIds,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue