
Introduces a dedicated search page for reception operations. Enables navigation to this new page from the 'Reception' quick action component, providing a dedicated interface for searching reception records. Registers the `ReceptionSearchRoute` to integrate it into the application's secure routing system. Also updates the empty state message on the reception list for improved localization and user experience.
38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
import 'package:e_scan/backend/api/api_calls.dart';
|
|
import 'package:e_scan/backend/objectbox/entities/stock_picking/stock_picking_record_entity.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
final receptionSearchPageModelProvider =
|
|
StateNotifierProvider.autoDispose<
|
|
ReceptionSearchPageModel,
|
|
AsyncValue<List<StockPickingRecordEntity>>
|
|
>((ref) {
|
|
return ReceptionSearchPageModel();
|
|
});
|
|
|
|
class ReceptionSearchPageModel
|
|
extends StateNotifier<AsyncValue<List<StockPickingRecordEntity>>> {
|
|
/// Constructor initializes the TaskRepository using the provider reference.
|
|
ReceptionSearchPageModel() : super(const AsyncValue.loading());
|
|
|
|
Future<void> allByName({required String name}) async {
|
|
try {
|
|
state = AsyncValue.loading();
|
|
final res = await ApiCalls.getAllStockPiking();
|
|
res.when(
|
|
(data) async {
|
|
final founds = data
|
|
.where((e) => e.name?.contains(name) == true)
|
|
.toList();
|
|
state = AsyncValue.data(founds);
|
|
},
|
|
(error) {
|
|
state = AsyncValue.error(error, StackTrace.current);
|
|
},
|
|
);
|
|
} catch (e) {
|
|
state = AsyncValue.error(e, StackTrace.current);
|
|
}
|
|
}
|
|
}
|