barcode_scanner/lib/pages/operation/reception/reception_search_page_model.dart
mandreshope 0b4e5042cc feat: Implements reception search page
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.
2025-08-04 15:29:52 +03:00

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);
}
}
}