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:
@@ -4,10 +4,16 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../core/api/api_error_mapper.dart';
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
import '../../profile/data/profile_repository.dart';
|
||||
import 'admin_ai_panel.dart';
|
||||
import 'admin_aliases_panel.dart';
|
||||
import 'admin_inventory_panel.dart';
|
||||
import 'admin_pantry_panel.dart';
|
||||
import 'admin_private_products_panel.dart';
|
||||
import 'admin_pending_products_panel.dart';
|
||||
import 'admin_products_panel.dart';
|
||||
import '../../profile/data/profile_repository.dart';
|
||||
|
||||
enum _DatabaseTab { inventory, pantry, products }
|
||||
enum _DatabaseTab { inventory, pantry, products, privateProducts, pending, aliases, ai }
|
||||
|
||||
class AdminDatabasePanel extends ConsumerStatefulWidget {
|
||||
final bool embedded;
|
||||
@@ -76,49 +82,124 @@ class _AdminDatabasePanelState extends ConsumerState<AdminDatabasePanel> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _panelShell({
|
||||
required String title,
|
||||
required String description,
|
||||
required Widget child,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(title, style: Theme.of(context).textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
Text(description),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
child,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
String tabLabel(_DatabaseTab tab) {
|
||||
switch (tab) {
|
||||
case _DatabaseTab.inventory:
|
||||
return context.l10n.profileInventoryTab;
|
||||
case _DatabaseTab.pantry:
|
||||
return context.l10n.profilePantryTab;
|
||||
case _DatabaseTab.products:
|
||||
return context.l10n.profileProductsTab;
|
||||
}
|
||||
return switch (tab) {
|
||||
_DatabaseTab.inventory => context.l10n.profileInventoryTab,
|
||||
_DatabaseTab.pantry => context.l10n.profilePantryTab,
|
||||
_DatabaseTab.products => context.l10n.profileProductsTab,
|
||||
_DatabaseTab.privateProducts => 'Privata produkter',
|
||||
_DatabaseTab.pending => context.l10n.profilePendingTab,
|
||||
_DatabaseTab.aliases => 'Alias',
|
||||
_DatabaseTab.ai => 'AI',
|
||||
};
|
||||
}
|
||||
|
||||
Widget activeSection;
|
||||
switch (_activeTab) {
|
||||
case _DatabaseTab.inventory:
|
||||
activeSection = _sectionCard(
|
||||
icon: Icons.inventory_2_outlined,
|
||||
activeSection = _panelShell(
|
||||
title: context.l10n.profileInventoryTab,
|
||||
description: context.l10n.profileInventoryDescription,
|
||||
onPressed: () => context.go('/inventory'),
|
||||
buttonLabel: context.l10n.profileOpenInventory,
|
||||
description: 'Granska, filtrera och redigera inventory-poster. Välj användare för att arbeta på en specifik ägares data.',
|
||||
child: const AdminInventoryPanel(embedded: true),
|
||||
);
|
||||
case _DatabaseTab.pantry:
|
||||
activeSection = _sectionCard(
|
||||
icon: Icons.storefront_outlined,
|
||||
activeSection = _panelShell(
|
||||
title: context.l10n.profilePantryTab,
|
||||
description: context.l10n.profilePantryDescription,
|
||||
onPressed: () => context.go('/baslager'),
|
||||
buttonLabel: context.l10n.profileOpenPantry,
|
||||
description: 'Granska och redigera användarnas baslager. Flytta poster till inventarie eller ta bort dem vid behov.',
|
||||
child: const AdminPantryPanel(embedded: true),
|
||||
);
|
||||
case _DatabaseTab.products:
|
||||
activeSection = const AdminProductsPanel(embedded: true);
|
||||
activeSection = _panelShell(
|
||||
title: context.l10n.profileProductsTab,
|
||||
description: 'Hantera globala produkter: kategorisering, restaurering, merge och AI-stöd.',
|
||||
child: const AdminProductsPanel(embedded: true),
|
||||
);
|
||||
case _DatabaseTab.privateProducts:
|
||||
activeSection = _panelShell(
|
||||
title: 'Privata produkter',
|
||||
description: 'Promotera privata produkter till den globala produkt-tabellen.',
|
||||
child: const AdminPrivateProductsPanel(embedded: true),
|
||||
);
|
||||
case _DatabaseTab.pending:
|
||||
activeSection = _panelShell(
|
||||
title: context.l10n.profilePendingTab,
|
||||
description: 'Godkänn eller avslå nya produkter som föreslagits av användare.',
|
||||
child: const AdminPendingProductsPanel(embedded: true),
|
||||
);
|
||||
case _DatabaseTab.aliases:
|
||||
activeSection = _panelShell(
|
||||
title: 'Alias',
|
||||
description: 'Hantera globala alias som används i receipt-importens första matchningssteg.',
|
||||
child: const AdminAliasesPanel(embedded: true),
|
||||
);
|
||||
case _DatabaseTab.ai:
|
||||
activeSection = _panelShell(
|
||||
title: 'AI',
|
||||
description: 'Se vilka AI-modeller som används och hur de är exponerade i systemet.',
|
||||
child: const AdminAiPanel(embedded: true),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: widget.embedded ? EdgeInsets.zero : const EdgeInsets.all(16),
|
||||
final header = SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
context.l10n.profileDatabaseDescription,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Databas', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Arbetsyta för data med tydlig scope: inventory och baslager är användarspecifika, produkter är globala eller privata och alias styr importmatchning.',
|
||||
style: theme.textTheme.bodyMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
Chip(label: Text('User-scope')),
|
||||
Chip(label: Text('Global scope')),
|
||||
Chip(label: Text('Private products')),
|
||||
Chip(label: Text('Alias')),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Card(
|
||||
@@ -127,15 +208,9 @@ class _AdminDatabasePanelState extends ConsumerState<AdminDatabasePanel> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Adminverktyg',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
Text('Adminverktyg', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Uppdatera kategorier manuellt i backend-cachen.',
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
Text('Uppdatera kategorier manuellt i backend-cachen.', style: theme.textTheme.bodyMedium),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
@@ -173,8 +248,18 @@ class _AdminDatabasePanelState extends ConsumerState<AdminDatabasePanel> {
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return Padding(
|
||||
padding: widget.embedded ? EdgeInsets.zero : const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(flex: 2, child: header),
|
||||
const SizedBox(height: 16),
|
||||
activeSection,
|
||||
Expanded(flex: 5, child: activeSection),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user