
Refactors the product data model to primarily store `id`, `barcode`, and `displayName`. This simplifies the product structure, focusing on essential attributes for inventory and scanning operations. Optimizes API calls for stock picking to fetch more relevant product details. Unnecessary fields are removed, and specific product attributes like `barcode` and `quantity` are now explicitly requested for stock moves. Moves `StockPickingRecordModel` to its own dedicated file for improved code organization and maintainability. Updates all affected UI components and scanner logic to align with the revised product model.
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/schema/stock_picking/stock_picking_record_model.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'reception_details_page_model.freezed.dart';
|
|
|
|
final receptionDetailsPageModelProvider =
|
|
StateNotifierProvider.autoDispose<
|
|
ReceptionDetailsPageModel,
|
|
ReceptionDetailsPageState
|
|
>((ref) {
|
|
return ReceptionDetailsPageModel();
|
|
});
|
|
|
|
class ReceptionDetailsPageModel
|
|
extends StateNotifier<ReceptionDetailsPageState> {
|
|
ReceptionDetailsPageModel() : super(const ReceptionDetailsPageState());
|
|
|
|
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 ReceptionDetailsPageState with _$ReceptionDetailsPageState {
|
|
const factory ReceptionDetailsPageState({
|
|
StockPickingRecordModel? reception,
|
|
@Default(false) bool loading,
|
|
}) = _ReceptionDetailsPageState;
|
|
}
|