This commit is contained in:
2025-10-28 23:46:07 +07:00
parent 73b77c27de
commit f32e1c16fb
10 changed files with 333 additions and 142 deletions

View File

@@ -4,6 +4,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../../core/di/providers.dart';
import '../../../../core/router/app_router.dart';
import '../widgets/warehouse_card.dart';
import '../widgets/warehouse_drawer.dart';
/// Warehouse selection page
/// Displays a list of warehouses and allows user to select one
@@ -26,11 +27,10 @@ class _WarehouseSelectionPageState
@override
void initState() {
super.initState();
// Load warehouses and sync users when page is first created
// Load warehouses when page is first created
Future.microtask(() {
ref.read(warehouseProvider.notifier).loadWarehouses();
// Sync users from API and save to local storage
ref.read(usersProvider.notifier).syncUsers();
// Users are automatically loaded from local storage by UsersNotifier
});
}
@@ -44,17 +44,18 @@ class _WarehouseSelectionPageState
return Scaffold(
appBar: AppBar(
title: const Text('Select Warehouse'),
title: const Text('Chọn kho'),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: () {
ref.read(warehouseProvider.notifier).loadWarehouses();
},
tooltip: 'Refresh',
tooltip: 'Làm mới',
),
],
),
drawer: const WarehouseDrawer(),
body: _buildBody(
isLoading: isLoading,
error: error,
@@ -77,7 +78,7 @@ class _WarehouseSelectionPageState
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('Loading warehouses...'),
Text('Đang tải danh sách kho...'),
],
),
);
@@ -98,7 +99,7 @@ class _WarehouseSelectionPageState
),
const SizedBox(height: 16),
Text(
'Error Loading Warehouses',
'Lỗi tải danh sách kho',
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 8),
@@ -113,7 +114,7 @@ class _WarehouseSelectionPageState
ref.read(warehouseProvider.notifier).loadWarehouses();
},
icon: const Icon(Icons.refresh),
label: const Text('Retry'),
label: const Text('Thử lại'),
),
],
),
@@ -136,12 +137,12 @@ class _WarehouseSelectionPageState
),
const SizedBox(height: 16),
Text(
'No Warehouses Available',
'Không có kho',
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 8),
Text(
'There are no warehouses to display.',
'Không có kho nào để hiển thị.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium,
),
@@ -151,7 +152,7 @@ class _WarehouseSelectionPageState
ref.read(warehouseProvider.notifier).loadWarehouses();
},
icon: const Icon(Icons.refresh),
label: const Text('Refresh'),
label: const Text('Làm mới'),
),
],
),