- Fixed _addModifiersRecursively to track OrderLineItemID through recursion - Changed from hardcoded parentOrderLineItemId: 0 to actual parent IDs - Added logic to find root item's OrderLineItemID before starting recursion - Added logic to find each modifier's OrderLineItemID for its children - Fixed API_BASE_URL to AALISTS_API_BASE_URL for environment consistency - Added comprehensive debug logging for troubleshooting This fix ensures nested modifiers (e.g., Customize Spread > Extra) are properly saved to the database with correct parent-child relationships. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
86 lines
1.7 KiB
Dart
86 lines
1.7 KiB
Dart
import "package:flutter/foundation.dart";
|
|
|
|
class AppState extends ChangeNotifier {
|
|
int? _selectedBusinessId;
|
|
int? _selectedServicePointId;
|
|
|
|
int? _userId;
|
|
|
|
int? _cartOrderId;
|
|
String? _cartOrderUuid;
|
|
int _cartItemCount = 0;
|
|
|
|
|
|
int? get selectedBusinessId => _selectedBusinessId;
|
|
int? get selectedServicePointId => _selectedServicePointId;
|
|
|
|
int? get userId => _userId;
|
|
bool get isLoggedIn => _userId != null && _userId! > 0;
|
|
|
|
int? get cartOrderId => _cartOrderId;
|
|
String? get cartOrderUuid => _cartOrderUuid;
|
|
int get cartItemCount => _cartItemCount;
|
|
|
|
|
|
bool get hasLocationSelection =>
|
|
_selectedBusinessId != null && _selectedServicePointId != null;
|
|
|
|
void setBusiness(int businessId) {
|
|
_selectedBusinessId = businessId;
|
|
_selectedServicePointId = null;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setServicePoint(int servicePointId) {
|
|
_selectedServicePointId = servicePointId;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
|
|
notifyListeners();
|
|
}
|
|
|
|
void setUserId(int userId) {
|
|
_userId = userId;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearAuth() {
|
|
_userId = null;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setCartOrder({required int orderId, required String orderUuid, int itemCount = 0}) {
|
|
_cartOrderId = orderId;
|
|
_cartOrderUuid = orderUuid;
|
|
_cartItemCount = itemCount;
|
|
notifyListeners();
|
|
}
|
|
|
|
void updateCartItemCount(int count) {
|
|
_cartItemCount = count;
|
|
notifyListeners();
|
|
}
|
|
|
|
void clearCart() {
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
_cartItemCount = 0;
|
|
notifyListeners();
|
|
}
|
|
|
|
|
|
void clearAll() {
|
|
_selectedBusinessId = null;
|
|
_selectedServicePointId = null;
|
|
|
|
_cartOrderId = null;
|
|
_cartOrderUuid = null;
|
|
|
|
|
|
}
|
|
}
|