Fix inactive item filtering and radio button behavior

- 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 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-01 11:43:04 -08:00
parent 9c91737b1a
commit ca16672f8c
3 changed files with 23 additions and 7 deletions

View file

@ -73,10 +73,20 @@ class _CartViewScreenState extends State<CartViewScreen> {
// Update item count in app state // Update item count in app state
appState.updateCartItemCount(cart.itemCount); appState.updateCartItemCount(cart.itemCount);
} catch (e) { } catch (e) {
setState(() { // If cart not found (deleted or doesn't exist), clear it from app state
_error = e.toString(); if (e.toString().contains('not_found') || e.toString().contains('Order not found')) {
_isLoading = false; final appState = context.read<AppState>();
}); appState.clearCart();
setState(() {
_cart = null;
_isLoading = false;
});
} else {
setState(() {
_error = e.toString();
_isLoading = false;
});
}
} }
} }

View file

@ -78,6 +78,9 @@ class _MenuBrowseScreenState extends State<MenuBrowseScreen> {
_itemsByParent.clear(); _itemsByParent.clear();
for (final item in _allItems) { for (final item in _allItems) {
// Skip inactive items
if (!item.isActive) continue;
if (item.isRootItem) { if (item.isRootItem) {
_itemsByCategory.putIfAbsent(item.categoryId, () => []).add(item); _itemsByCategory.putIfAbsent(item.categoryId, () => []).add(item);
} else { } else {
@ -842,15 +845,19 @@ class _ItemCustomizationSheetState extends State<_ItemCustomizationSheet> {
final isCurrentlySelected = _selectedItemIds.contains(item.itemId); 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) { if (parent.maxNumSelectionReq == 1) {
final siblings = widget.itemsByParent[parent.itemId] ?? []; final siblings = widget.itemsByParent[parent.itemId] ?? [];
for (final sibling in siblings) { for (final sibling in siblings) {
_selectedItemIds.remove(sibling.itemId); _selectedItemIds.remove(sibling.itemId);
_deselectDescendants(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) { if (isCurrentlySelected) {
// Deselect this item and all descendants // Deselect this item and all descendants
_selectedItemIds.remove(item.itemId); _selectedItemIds.remove(item.itemId);

View file

@ -58,9 +58,8 @@ class Api {
} }
static String get baseUrl { static String get baseUrl {
const v = String.fromEnvironment("AALISTS_API_BASE_URL"); const v = String.fromEnvironment("PAYFRIT_API_BASE_URL");
if (v.isEmpty) { if (v.isEmpty) {
// Default to production API
return "https://biz.payfrit.com/api"; return "https://biz.payfrit.com/api";
} }
return v; return v;