barcode_scanner/lib/pages/operation/reception/reception_page_model.dart
mandreshope 61047f266d chore: Renames project to e_scan
Performs a comprehensive project rename from 'barcode_scanner' to 'e_scan' (or 'eScan' for user-facing labels). This update spans all relevant files, including:

- Application IDs and bundle identifiers for Android, iOS, macOS, and Linux.
- VS Code launch configurations.
- Dart package import paths.
- Project names and titles in `pubspec.yaml`, `README.md`, and platform-specific configurations (e.g., CMakeLists, Info.plist, AndroidManifest).
2025-07-30 09:19:44 +03:00

68 lines
2.2 KiB
Dart

import 'package:e_scan/backend/api/api_calls.dart';
import 'package:e_scan/backend/schema/stock_picking/stock_picking_model.dart';
import 'package:e_scan/backend/schema/user/user_struct.dart';
import 'package:e_scan/services/secure_storage.dart';
import 'package:e_scan/services/token_provider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'reception_page_model.freezed.dart';
final receptionPageModelProvider =
StateNotifierProvider<ReceptionPageModel, ReceptionPageState>((ref) {
return ReceptionPageModel(
secureStorage: ref.read(sharedPrefsProvider),
tokenProvider: ref.read(tokenProvider),
userConnectedProvider: ref.read(userConnectedProvider),
);
});
class ReceptionPageModel extends StateNotifier<ReceptionPageState> {
ReceptionPageModel({
required this.secureStorage,
required this.tokenProvider,
required this.userConnectedProvider,
}) : super(const ReceptionPageState()) {
getAllReceptions();
}
late FlutterSecureStorage secureStorage;
late TokenProvider tokenProvider;
final UserConnectedProvider userConnectedProvider;
Future getUserConnected() async {
state = state.copyWith(loadingUser: true);
final user = await userConnectedProvider.get();
state = state.copyWith(user: user, loadingUser: false);
}
Future getAllReceptions() async {
try {
state = state.copyWith(loadingReceptions: true);
final res = await ApiCalls.getAllStockPiking();
res.when(
(data) {
state = state.copyWith(receptions: data, loadingReceptions: false);
},
(error) {
state = state.copyWith(loadingReceptions: false);
},
);
} catch (e) {
state = state.copyWith(loadingReceptions: false);
}
}
}
@freezed
abstract class ReceptionPageState with _$ReceptionPageState {
const factory ReceptionPageState({
UserStruct? user,
StockPickingResponseModel? receptions,
@Default(false) bool loadingReceptions,
@Default(false) bool loadingUser,
}) = _ReceptionPageState;
}