84ccabe2fe
Test Suite / test (24.15.0) (push) Has been cancelled
- Implemented moveInventoryItemToPantry method in InventoryRepository to facilitate moving items from inventory to pantry. - Enhanced InventoryScreen with a new header section providing context about the inventory. - Added a button in SwipeableInventoryTile to move items to pantry with appropriate error handling. - Introduced movePantryItemToInventory method in PantryRepository to support moving items back to inventory. - Refactored PantryScreen to rename _addToInventory to _moveToInventory for clarity and updated UI to reflect changes. - Added AdminPantryItem model to represent pantry items in the admin panel. - Created AdminPantryPanel for managing pantry items, including moving items to inventory and listing users. - Developed AdminPrivateProductsPanel for managing private products, allowing promotion to global products.
42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
Dart
class AdminPantryItem {
|
|
final int id;
|
|
final int userId;
|
|
final String username;
|
|
final String userEmail;
|
|
final int productId;
|
|
final String productName;
|
|
final String? productCanonicalName;
|
|
final String? location;
|
|
|
|
const AdminPantryItem({
|
|
required this.id,
|
|
required this.userId,
|
|
required this.username,
|
|
required this.userEmail,
|
|
required this.productId,
|
|
required this.productName,
|
|
this.productCanonicalName,
|
|
this.location,
|
|
});
|
|
|
|
String get displayName {
|
|
final canonical = productCanonicalName?.trim();
|
|
if (canonical != null && canonical.isNotEmpty) return canonical;
|
|
return productName;
|
|
}
|
|
|
|
factory AdminPantryItem.fromJson(Map<String, dynamic> json) {
|
|
final user = (json['user'] as Map<String, dynamic>?) ?? const {};
|
|
final product = (json['product'] as Map<String, dynamic>?) ?? const {};
|
|
return AdminPantryItem(
|
|
id: (json['id'] as num).toInt(),
|
|
userId: (json['userId'] as num).toInt(),
|
|
username: user['username'] as String? ?? '',
|
|
userEmail: user['email'] as String? ?? '',
|
|
productId: (json['productId'] as num).toInt(),
|
|
productName: product['name'] as String? ?? '',
|
|
productCanonicalName: product['canonicalName'] as String?,
|
|
location: json['location'] as String?,
|
|
);
|
|
}
|
|
} |