feat: Add functionality to move inventory items to pantry and enhance pantry management
Test Suite / test (24.15.0) (push) Has been cancelled
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.
This commit is contained in:
@@ -37,3 +37,56 @@ SnackBar buildCopyableErrorSnackBar(BuildContext context, String message) {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildCopyableErrorPanel({
|
||||
required BuildContext context,
|
||||
required String message,
|
||||
required VoidCallback onRetry,
|
||||
String title = 'Ett fel uppstod',
|
||||
}) {
|
||||
return Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 720),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.all(16),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
SelectableText(message),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
onPressed: onRetry,
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: Text(context.l10n.retryAction),
|
||||
),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: message));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(context.l10n.errorDialogCopied)),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.copy_all),
|
||||
label: Text(context.l10n.errorDialogCopy),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ class ProductApiPaths {
|
||||
static const list = '/products';
|
||||
static const mine = '/products/mine';
|
||||
static const createPrivate = '/products/private';
|
||||
static const privateList = '/products/private';
|
||||
static String promotePrivate(int id) => '/products/private/$id/promote';
|
||||
static const pending = '/products/pending';
|
||||
static const aiCategorizeBulk = '/products/ai-categorize-bulk';
|
||||
static const deleted = '/products/deleted';
|
||||
@@ -59,6 +61,8 @@ class InventoryApiPaths {
|
||||
static const list = '/inventory';
|
||||
static String update(int id) => '/inventory/$id';
|
||||
static String remove(int id) => '/inventory/$id';
|
||||
static String moveToPantry(int id) => '/inventory/$id/move-to-pantry';
|
||||
static String moveToPantryAdmin(int id) => '/inventory/admin/$id/move-to-pantry';
|
||||
static String consume(int id) => '/inventory/$id/consume';
|
||||
static String consumptionHistory(int id) => '/inventory/$id/consumption-history';
|
||||
}
|
||||
@@ -77,6 +81,7 @@ class AdminInventoryApiPaths {
|
||||
}
|
||||
static String update(int id) => '/inventory/admin/$id';
|
||||
static String remove(int id) => '/inventory/admin/$id';
|
||||
static String moveToPantry(int id) => '/inventory/admin/$id/move-to-pantry';
|
||||
static const merge = '/inventory/admin/merge';
|
||||
static String mergePreview(int sourceInventoryId, int targetInventoryId) =>
|
||||
'/inventory/admin/merge-preview?sourceInventoryId=$sourceInventoryId&targetInventoryId=$targetInventoryId';
|
||||
@@ -85,6 +90,10 @@ class AdminInventoryApiPaths {
|
||||
class PantryApiPaths {
|
||||
static const list = '/pantry';
|
||||
static String remove(int id) => '/pantry/$id';
|
||||
static String moveToInventory(int id) => '/pantry/$id/move-to-inventory';
|
||||
static String moveToInventoryAdmin(int id) => '/pantry/admin/$id/move-to-inventory';
|
||||
static const adminList = '/pantry/admin';
|
||||
static String adminRemove(int id) => '/pantry/admin/$id';
|
||||
}
|
||||
|
||||
class UserApiPaths {
|
||||
|
||||
Reference in New Issue
Block a user