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:
parent
9c91737b1a
commit
ca16672f8c
3 changed files with 23 additions and 7 deletions
|
|
@ -73,12 +73,22 @@ class _CartViewScreenState extends State<CartViewScreen> {
|
|||
// Update item count in app state
|
||||
appState.updateCartItemCount(cart.itemCount);
|
||||
} catch (e) {
|
||||
// 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>();
|
||||
appState.clearCart();
|
||||
setState(() {
|
||||
_cart = null;
|
||||
_isLoading = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_error = e.toString();
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _removeLineItem(OrderLineItem lineItem) async {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ class _MenuBrowseScreenState extends State<MenuBrowseScreen> {
|
|||
_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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue