From ca16672f8c17d3bdb12f44f84d3c7f5b9b222780 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Thu, 1 Jan 2026 11:43:04 -0800 Subject: [PATCH] Fix inactive item filtering and radio button behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Filter out inactive items (ItemIsActive=0) in menu modifier display - Fix radio button groups to prevent deselection (can only switch) - Add cart clearing on "order not found" errors - Simplify API base URL configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- lib/screens/cart_view_screen.dart | 18 ++++++++++++++---- lib/screens/menu_browse_screen.dart | 9 ++++++++- lib/services/api.dart | 3 +-- 3 files changed, 23 insertions(+), 7 deletions(-) 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;