diff --git a/lib/screens/cart_view_screen.dart b/lib/screens/cart_view_screen.dart index 7b2129c..b649cbb 100644 --- a/lib/screens/cart_view_screen.dart +++ b/lib/screens/cart_view_screen.dart @@ -73,10 +73,20 @@ class _CartViewScreenState extends State { // Update item count in app state appState.updateCartItemCount(cart.itemCount); } catch (e) { - setState(() { - _error = e.toString(); - _isLoading = false; - }); + // If cart not found (deleted or doesn't exist), clear it from app state + if (e.toString().contains('not_found') || e.toString().contains('Order not found')) { + final appState = context.read(); + appState.clearCart(); + setState(() { + _cart = null; + _isLoading = false; + }); + } else { + setState(() { + _error = e.toString(); + _isLoading = false; + }); + } } } diff --git a/lib/screens/menu_browse_screen.dart b/lib/screens/menu_browse_screen.dart index 64a156c..11b29d9 100644 --- a/lib/screens/menu_browse_screen.dart +++ b/lib/screens/menu_browse_screen.dart @@ -78,6 +78,9 @@ class _MenuBrowseScreenState extends State { _itemsByParent.clear(); for (final item in _allItems) { + // Skip inactive items + if (!item.isActive) continue; + if (item.isRootItem) { _itemsByCategory.putIfAbsent(item.categoryId, () => []).add(item); } else { @@ -842,15 +845,19 @@ class _ItemCustomizationSheetState extends State<_ItemCustomizationSheet> { final isCurrentlySelected = _selectedItemIds.contains(item.itemId); - // For radio buttons (max = 1), deselect siblings + // For radio buttons (max = 1), deselect siblings and always select the clicked item if (parent.maxNumSelectionReq == 1) { final siblings = widget.itemsByParent[parent.itemId] ?? []; for (final sibling in siblings) { _selectedItemIds.remove(sibling.itemId); _deselectDescendants(sibling.itemId); } + // Always select the clicked item (radio buttons can't be deselected) + _selectedItemIds.add(item.itemId); + return; } + // For checkboxes, allow toggle on/off if (isCurrentlySelected) { // Deselect this item and all descendants _selectedItemIds.remove(item.itemId); diff --git a/lib/services/api.dart b/lib/services/api.dart index c20cae7..3a800b4 100644 --- a/lib/services/api.dart +++ b/lib/services/api.dart @@ -58,9 +58,8 @@ class Api { } static String get baseUrl { - const v = String.fromEnvironment("AALISTS_API_BASE_URL"); + const v = String.fromEnvironment("PAYFRIT_API_BASE_URL"); if (v.isEmpty) { - // Default to production API return "https://biz.payfrit.com/api"; } return v;