
Replaces the generic scanner route with a dedicated reception scanning page. This change ensures the scanning process initiated from reception details is context-aware by passing the reception ID directly to the new `ReceptionScanPage`. This provides a more tailored and efficient workflow for reception operations.
46 lines
1.4 KiB
Dart
46 lines
1.4 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/foundation.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'reception_scan_page_model.freezed.dart';
|
|
|
|
final receptionScanPageModelProvider =
|
|
StateNotifierProvider.autoDispose<
|
|
ReceptionScanPageModel,
|
|
ReceptionScanPageModelState
|
|
>((ref) {
|
|
return ReceptionScanPageModel();
|
|
});
|
|
|
|
class ReceptionScanPageModel
|
|
extends StateNotifier<ReceptionScanPageModelState> {
|
|
ReceptionScanPageModel() : super(const ReceptionScanPageModelState());
|
|
|
|
Future getReceptionById({required int id}) async {
|
|
try {
|
|
state = state.copyWith(loading: true);
|
|
final res = await ApiCalls.getStockPikingById(id: id);
|
|
res.when(
|
|
(data) {
|
|
state = state.copyWith(loading: false, reception: data);
|
|
},
|
|
(error) {
|
|
state = state.copyWith(loading: false);
|
|
},
|
|
);
|
|
} catch (e) {
|
|
state = state.copyWith(loading: false);
|
|
}
|
|
}
|
|
}
|
|
|
|
@freezed
|
|
abstract class ReceptionScanPageModelState with _$ReceptionScanPageModelState {
|
|
const factory ReceptionScanPageModelState({
|
|
StockPickingRecordEntity? reception,
|
|
@Default(false) bool loading,
|
|
}) = _ReceptionScanPageModelState;
|
|
}
|